logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laurent Hasson" <...@CapsicoHealth.com>
Subject Questions about RollingFile
Date Thu, 19 May 2016 03:18:45 GMT
Hello,

 

I have the following XML configuration file for my webapp (under Tomcat 9).

 

<?xml version="1.0" encoding="UTF-8"?>

<Configuration status="info">

       <Properties>

              <Property
name="log-path">C:\Projects\TomcatDevServer\logs\</Property>

              <Property name="now">${sys:startup}</Property>

       </Properties>

       <Appenders>

              <RollingFile name="FILES" fileName="${log-path}/capsico.log"
filePattern="${log-path}/capsico.${now}.%i.log.gz">

                     <PatternLayout>

                     <pattern>%d{MMdd.HHmmss.SSS}#%-3t %level{length=1}
%15.15c{1}|  %m%ex{20}%n</pattern>

                     </PatternLayout>

                     <Policies>

                           <SizeBasedTriggeringPolicy size="100 MB" />

                     </Policies>

                     <DefaultRolloverStrategy max="99999"
compressionLevel="9"/>

              </RollingFile>

              <Async name="ASYNC">

                     <AppenderRef ref="FILES" />

              </Async>

       </Appenders>

       <Loggers>

              <Root level="debug">

                     <AppenderRef ref="ASYNC" />

              </Root>

       </Loggers>

</Configuration>

 

I have done one thing that I haven't seen in any example, which is that all
the logs are tagged with the timestamp of when the system started (using
${sys:startup}), rather than using an inline timestamp format. This allows
me to group all log files per "server startup". This works well. 

 

Now, I would like to do the same thing for the initial/starting file, and I
have tried fileName="${log-path}/capsico.${sys:startup}.log" but with no
success. I have also tried:

-          fileName="${log-path}/capsico.$${sys:startup}.log"

-          fileName="${log-path}/capsico.${now}.log"

-          fileName="${log-path}/capsico.$S{now}.log"

 

I find this easier to manage in development or when troubleshooting
deployment issues where the server may be re-started multiple times: instead
of having a single "start" file with all the logging appended across
multiple server restart, I would like to always get a new clean file
everytime.

 

Can this be done? I am sure there is a way by writing some Java code and
all, but trying to figure out a config-level way first if available.

 

Thank you,

 

Laurent Hasson
Co-Founder and CTO

CapsicoHealth Inc.

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message