logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laurent Hasson" <...@CapsicoHealth.com>
Subject RE: Add a pattern to the first rolling file created...
Date Wed, 13 Jul 2016 16:36:01 GMT
That's a bit different from what I needed... But maybe I am approaching this
from the wrong angle. In  our setup, we can start multiple instances of the
same server. They are typically started separately, so the date of the JVM
start would be different (let's assume this to be true for our case). I
didn't want to maintain multiple log4j xml config files. What I wanted was
something like.

 

capsico.2016-07-13_12-06-16.log (where 2016-07-13_12-06-16 is the timestamp
of when the first server/jvm started)

capsico.2016-07-13_12-06-16.1.gz

capsico.2016-07-13_12-06-16.2.gz

capsico.2016-07-13_12-06-16.3.gz

 

capsico.2016-07-13_12-30-00.log (where 2016-07-13_12-30-00 is the timestamp
of when the second server/jvm started)

capsico.2016-07-13_12-30-00.1.gz

capsico.2016-07-13_12-30-00.2.gz

capsico.2016-07-13_12-30-00.3.gz

 

etc...

 

The 2 server instances are running in parallel, each within their own
sequence of log files. I thought that 

 

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

 

would enable me to do this, but it seems to be working erratically, or I am
not doing this properly as I am getting the error

 

2016-07-13 12:06:13,226 main ERROR Unable to rename file
C:\Projects\TomcatDevServer\logs\capsico.log to
C:\Projects\TomcatDevServer\logs\capsico.${sys:startup}.1.log:
java.nio.file.InvalidPathException Illegal char <:> at index 46:
C:\Projects\TomcatDevServer\logs\capsico.${sys:startup}.1.log

 

The weird part is that I am getting the GZ files alright in spite of the
error, but looks like a piece of the logs go missing. I have upgraded to
2.6.2 so I am on the latest and greatest.

 

Laurent Hasson

Co-Founder and CTO

CapsicoHealth Inc.

 

-----Original Message-----
From: Ralph Goers [mailto:ralph.goers@dslextreme.com] 
Sent: Wednesday, July 13, 2016 09:35
To: Log4J Users List <log4j-user@logging.apache.org>
Subject: Re: Add a pattern to the first rolling file created...

 

Please look at the OnStartupTriggeringPolicy - On Jul 13, 2016, at 5:44 AM,
Laurent Hasson < <mailto:ldh@CapsicoHealth.com> ldh@CapsicoHealth.com>
wrote:

<
<http://logging.apache.org/log4j/2.x/manual/appenders.html#OnStartup_Trigger
ing_Policy>
http://logging.apache.org/log4j/2.x/manual/appenders.html#OnStartup_Triggeri
ng_Policy>

Ralph

 

 

> 

> 

> Hello,

> 

> I would like to be able to add a pattern to the main logging file so that
a new file is created each time my server is re-started. This is the guts of
our config file:

> 

>             <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>

> 

> I have tried to add a pattern to the "filename" property for <RollingFile>
but without success. This means that right now, if the server is re-started,
the logging continues right into the existing file (everything else
regarding the rolling logic works as expected).

> 

> All I'd want is for a simple timestamp to be added, like the filePattern,
and if possibly, have the same timestamp of the system start reused. I think
I am missing something quite basic here? I am on log4J 2.5 on Java 8.

> 

> 

> Laurent Hasson

> Co-Founder and CTO

> CapsicoHealth Inc.


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