[logback-user] question about adding hostname to filenamepattern

haijia leonster at gmail.com
Wed May 18 21:53:56 CEST 2011


Hi, All,

 I'm running this issue with logback RollingFileAppender. Basically
when I need is the log file with following name pattern
 {hostname}log{YYYY-MM-DD-HH}.log

 Here's the config I'm using

       <appender name="searchRequestLog"
               class="ch.qos.logback.core.rolling.RollingFileAppender">
               <File>logs/searchrequestlog.log</File>
               <encoder>
                       <pattern> %m%n</pattern>
               </encoder>
               <rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

<FileNamePattern>logs/%property{searchhost}searchRequestLog.%d{yyyy-MM-dd-hh}.log</FileNamePattern>
               </rollingPolicy>
       </appender>

But the generated log file name is:
%PARSER_ERROR[property]searchRequestLog.2011-05-18-11.log


Can anyone help me on this? Thanks

Haijia


More information about the Logback-user mailing list