To be clear... the error described below only shows up if <OnStartupTriggeringPolicy /> is listed as a policy. No error show up otherwise.
Laurent Hasson Co-Founder and CTO CapsicoHealth Inc. -----Original Message----- From: Laurent Hasson [mailto:l...@capsicohealth.com] Sent: Wednesday, July 13, 2016 12:36 To: 'Log4J Users List' <log4j-user@logging.apache.org> Subject: RE: Add a pattern to the first rolling file created... 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.go...@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:l...@capsicohealth.com> l...@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. --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org