You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Laurent Hasson <ld...@CapsicoHealth.com> on 2018/02/24 19:13:51 UTC

Parametrizing file names with start date of process

Hello,

I'd like to parametrize my log file names with the start date of the process. This makes it easier for us to see after the facts in the logs if a server was restarted etc...

The approach I took was the following:
<Properties>
  <Property name="log-path">C:\CAPSICO\_Stand_Alone_Runtime_\logs\</Property>
  <Property name="now">%d{yyyy-MM-dd}</Property>
</Properties>
<Appenders>
  <RollingFile name="FILES" fileName="${log-path}/capsico.%{now}.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>
</Appenders>

My thinking is that ${now} would be resolved when the system starts, and then I could use the value in the file names. But the filenames print '${now}' directly.

Any help would be much appreciated.

Thank you,
Laurent.

Re: Parametrizing file names with start date of process

Posted by Matt Sicker <bo...@gmail.com>.
Wouldn't it make sense to use a header and/or footer for logging that start
and/or end time? Though encoding it in the file name makes sense.

On 24 February 2018 at 21:02, Ralph Goers <ra...@dslextreme.com>
wrote:

> ${xxx:nnn) is the general format for Lookups. ${date:} is the date Lookup.
> It returns the current date, which is exactly what you wanted.
>
> Ralph
>
> > On Feb 24, 2018, at 5:05 PM, Laurent Hasson <ld...@CapsicoHealth.com>
> wrote:
> >
> > Oh yes, apologies... I did some edits to simplify my config file and
> accidentally changed $ to %. It is correct in the file. I tried
> ${date:yyyy-MM-dd} and it works. I'll read up on what "date:" is.
> >
> > Thank you,
> > Laurent
> >
> > -----Original Message-----
> > From: Ralph Goers [mailto:ralph.goers@dslextreme.com]
> > Sent: Saturday, February 24, 2018 18:41
> > To: Log4J Users List <lo...@logging.apache.org>
> > Subject: Re: Parametrizing file names with start date of process
> >
> > First, you are referring to the variable as %{now} when it should be
> ${now}.  Second, all that is going to do is replace ${now} in the file name
> with %d{yyyy-MM-dd} which will then be resolved when the file is created.
> >
> > I would suggest defining now as ${date:yyyy-MM-dd}
> >
> > Ralph
> >
> >> On Feb 24, 2018, at 12:13 PM, Laurent Hasson <ld...@CapsicoHealth.com>
> wrote:
> >>
> >> Hello,
> >>
> >> I'd like to parametrize my log file names with the start date of the
> process. This makes it easier for us to see after the facts in the logs if
> a server was restarted etc...
> >>
> >> The approach I took was the following:
> >> <Properties>
> >> <Property
> >> name="log-path">C:\CAPSICO\_Stand_Alone_Runtime_\logs\</Property>
> >> <Property name="now">%d{yyyy-MM-dd}</Property>
> >> </Properties>
> >> <Appenders>
> >> <RollingFile name="FILES" fileName="${log-path}/capsico.%{now}.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> </Appenders>
> >>
> >> My thinking is that ${now} would be resolved when the system starts,
> and then I could use the value in the file names. But the filenames print
> '${now}' directly.
> >>
> >> Any help would be much appreciated.
> >>
> >> Thank you,
> >> Laurent.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
Matt Sicker <bo...@gmail.com>

Re: Parametrizing file names with start date of process

Posted by Ralph Goers <ra...@dslextreme.com>.
${xxx:nnn) is the general format for Lookups. ${date:} is the date Lookup. It returns the current date, which is exactly what you wanted.

Ralph

> On Feb 24, 2018, at 5:05 PM, Laurent Hasson <ld...@CapsicoHealth.com> wrote:
> 
> Oh yes, apologies... I did some edits to simplify my config file and accidentally changed $ to %. It is correct in the file. I tried ${date:yyyy-MM-dd} and it works. I'll read up on what "date:" is.
> 
> Thank you,
> Laurent 
> 
> -----Original Message-----
> From: Ralph Goers [mailto:ralph.goers@dslextreme.com] 
> Sent: Saturday, February 24, 2018 18:41
> To: Log4J Users List <lo...@logging.apache.org>
> Subject: Re: Parametrizing file names with start date of process
> 
> First, you are referring to the variable as %{now} when it should be ${now}.  Second, all that is going to do is replace ${now} in the file name with %d{yyyy-MM-dd} which will then be resolved when the file is created. 
> 
> I would suggest defining now as ${date:yyyy-MM-dd}
> 
> Ralph
> 
>> On Feb 24, 2018, at 12:13 PM, Laurent Hasson <ld...@CapsicoHealth.com> wrote:
>> 
>> Hello,
>> 
>> I'd like to parametrize my log file names with the start date of the process. This makes it easier for us to see after the facts in the logs if a server was restarted etc...
>> 
>> The approach I took was the following:
>> <Properties>
>> <Property 
>> name="log-path">C:\CAPSICO\_Stand_Alone_Runtime_\logs\</Property>
>> <Property name="now">%d{yyyy-MM-dd}</Property>
>> </Properties>
>> <Appenders>
>> <RollingFile name="FILES" fileName="${log-path}/capsico.%{now}.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> </Appenders>
>> 
>> My thinking is that ${now} would be resolved when the system starts, and then I could use the value in the file names. But the filenames print '${now}' directly.
>> 
>> Any help would be much appreciated.
>> 
>> Thank you,
>> Laurent.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Parametrizing file names with start date of process

Posted by Laurent Hasson <ld...@CapsicoHealth.com>.
Oh yes, apologies... I did some edits to simplify my config file and accidentally changed $ to %. It is correct in the file. I tried ${date:yyyy-MM-dd} and it works. I'll read up on what "date:" is.

Thank you,
Laurent 

-----Original Message-----
From: Ralph Goers [mailto:ralph.goers@dslextreme.com] 
Sent: Saturday, February 24, 2018 18:41
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: Parametrizing file names with start date of process

First, you are referring to the variable as %{now} when it should be ${now}.  Second, all that is going to do is replace ${now} in the file name with %d{yyyy-MM-dd} which will then be resolved when the file is created. 

I would suggest defining now as ${date:yyyy-MM-dd}

Ralph

> On Feb 24, 2018, at 12:13 PM, Laurent Hasson <ld...@CapsicoHealth.com> wrote:
> 
> Hello,
> 
> I'd like to parametrize my log file names with the start date of the process. This makes it easier for us to see after the facts in the logs if a server was restarted etc...
> 
> The approach I took was the following:
> <Properties>
>  <Property 
> name="log-path">C:\CAPSICO\_Stand_Alone_Runtime_\logs\</Property>
>  <Property name="now">%d{yyyy-MM-dd}</Property>
> </Properties>
> <Appenders>
>  <RollingFile name="FILES" fileName="${log-path}/capsico.%{now}.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> </Appenders>
> 
> My thinking is that ${now} would be resolved when the system starts, and then I could use the value in the file names. But the filenames print '${now}' directly.
> 
> Any help would be much appreciated.
> 
> Thank you,
> Laurent.



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Parametrizing file names with start date of process

Posted by Ralph Goers <ra...@dslextreme.com>.
First, you are referring to the variable as %{now} when it should be ${now}.  Second, all that is going to do is replace ${now} in the file name with %d{yyyy-MM-dd} which will then be resolved when the file is created. 

I would suggest defining now as ${date:yyyy-MM-dd}

Ralph

> On Feb 24, 2018, at 12:13 PM, Laurent Hasson <ld...@CapsicoHealth.com> wrote:
> 
> Hello,
> 
> I'd like to parametrize my log file names with the start date of the process. This makes it easier for us to see after the facts in the logs if a server was restarted etc...
> 
> The approach I took was the following:
> <Properties>
>  <Property name="log-path">C:\CAPSICO\_Stand_Alone_Runtime_\logs\</Property>
>  <Property name="now">%d{yyyy-MM-dd}</Property>
> </Properties>
> <Appenders>
>  <RollingFile name="FILES" fileName="${log-path}/capsico.%{now}.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>
> </Appenders>
> 
> My thinking is that ${now} would be resolved when the system starts, and then I could use the value in the file names. But the filenames print '${now}' directly.
> 
> Any help would be much appreciated.
> 
> Thank you,
> Laurent.



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org