Parametrizing file names with start date of process

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Parametrizing file names with start date of process

Laurent Hasson
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.
Reply | Threaded
Open this post in threaded view
|

Re: Parametrizing file names with start date of process

Ralph Goers
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 <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Parametrizing file names with start date of process

Laurent Hasson
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:[hidden email]]
Sent: Saturday, February 24, 2018 18:41
To: Log4J Users List <[hidden email]>
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 <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Parametrizing file names with start date of process

Ralph Goers
${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 <[hidden email]> 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:[hidden email]]
> Sent: Saturday, February 24, 2018 18:41
> To: Log4J Users List <[hidden email]>
> 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 <[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Parametrizing file names with start date of process

Matt Sicker
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 <[hidden email]>
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 <[hidden email]>
> 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:[hidden email]]
> > Sent: Saturday, February 24, 2018 18:41
> > To: Log4J Users List <[hidden email]>
> > 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 <[hidden email]>
> 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: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Matt Sicker <[hidden email]>