[logback-user] Dynamically change a variable value for file location
Douglas Moraes
doug.manoel at gmail.com
Tue Jun 14 17:58:51 UTC 2016
Hi Ceki,
Thanks for the answer.
Now I got success proceding like you suggested on preliminary tests.
Tomorrow I can confirm it.
Thanks a lot
Douglas
2016-06-14 13:00 GMT-03:00 Ceki Gulcu <ceki at qos.ch>:
>
>
> Hi Douglas,
>
>
> The <file> property is optional RollingFileAppender. Without it,
> RollingFileAppender will behave in the way you want.
>
> Try the following:
>
> <appender name="FILE"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
>
> <rollingPolicy
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
> <fileNamePattern./log/%d{MMdd}/gp2b.log</fileNamePattern>
> <maxHistory>30</maxHistory>
> </rollingPolicy>
> <encoder>
> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36}:%L -
> %msg%rEx{10}%n</pattern>
> </encoder>
> </appender>
>
> Let us know how it goes.
>
> --
> Ceki
>
>
>
>
> On 6/14/2016 17:14, Douglas Moraes wrote:
>
>> Hi,
>>
>> I want to save my log file in a directory accordingly the current day.
>> For example, if today is 0614 (June 14th), all log events will go to a
>> folder 0614, and tomorrow I want the logs to go to 0615.
>>
>> I donĀ“t want use rolling policy. I mean, I want the file to be directly
>> created in the right place, and not saved in a temporary place and in
>> other day to be saved in an archive place.
>>
>> I tryed:
>>
>> <configuration>
>> <timestamp key="DIR" datePattern="MMdd" />
>> <appender name="FILE"
>> class="ch.qos.logback.core.rolling.RollingFileAppender">
>> <file>./log/${DIR}/gp2b.log</file>
>> <rollingPolicy
>> class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
>> <fileNamePattern>app.%i.log</fileNamePattern>
>> <minIndex>1</minIndex>
>> <maxIndex>10</maxIndex>
>> </rollingPolicy>
>> <triggeringPolicy
>> class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
>> <maxFileSize>5MB</maxFileSize>
>> </triggeringPolicy>
>> <encoder>
>> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36}:%L
>> - %msg%rEx{10}%n</pattern>
>> </encoder>
>> </appender>
>>
>> <logger name="com.ocs.ProxyHttp.gp2b" level="DEBUG" />
>>
>> <root level="DEBUG">
>> <appender-ref ref="FILE" />
>> </root>
>> </configuration>
>>
>>
>> Thanks,
>> Douglas
>>
>>
>> _______________________________________________
>> logback-user mailing list
>> logback-user at qos.ch
>> http://mailman.qos.ch/mailman/listinfo/logback-user
>>
>> _______________________________________________
> logback-user mailing list
> logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20160614/484b257d/attachment.html>
More information about the logback-user
mailing list