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 流子℡ <41...@qq.com> on 2016/06/19 15:09:00 UTC
Question about how to create new log files on an hourly not depend on new byte stream log appended
hi,
here is my log config as follows:
<RollingRandomAccessFile name="LingyuLog" fileName="game" filePattern="game.%d{yyyy-MM-dd-HH}.log"> <PatternLayout pattern="%msg%n" /> <Policies> <TimeBasedTriggeringPolicy interval="1" modulate="true" /> </Policies> </RollingRandomAccessFile>
As we know,for instance,now is 22:55 pm,the active file named 'game' is printed continuously,
at 23:00 pm ,the first byte stream out will trigger the file named 'game' rename to game.2016-06-19-22.log,and print the byte stream to the new file named 'game'. if no other byte stream in the next one hour, the behavior will not be triggered.
it will lead to that the log will be batch inserted into mysql db delay if we only pick up the file having suffix '.log'.
because the content still remain in file named 'game' not be suffix '.log'.
my question is how to create new log files on an hourly not depend on new byte stream log appended.
yours
Allen
Re: Question about how to create new log files on an hourly not
depend on new byte stream log appended
Posted by Remko Popma <re...@gmail.com>.
Allen,
Please take a look at the CronTriggeringPolicy.
Remko
On Mon, Jun 20, 2016 at 12:09 AM, 流子℡ <41...@qq.com> wrote:
> hi,
> here is my log config as follows:
>
>
> <RollingRandomAccessFile name="LingyuLog"
> fileName="game"
> filePattern="game.%d{yyyy-MM-dd-HH}.log">
> <PatternLayout pattern="%msg%n" /> <Policies>
> <TimeBasedTriggeringPolicy interval="1"
> modulate="true" /> </Policies>
> </RollingRandomAccessFile>
>
> As we know,for instance,now is 22:55 pm,the active file named 'game' is
> printed continuously,
> at 23:00 pm ,the first byte stream out will trigger the file named 'game'
> rename to game.2016-06-19-22.log,and print the byte stream to the new
> file named 'game'. if no other byte stream in the next one hour, the
> behavior will not be triggered.
> it will lead to that the log will be batch inserted into mysql db delay if
> we only pick up the file having suffix '.log'.
> because the content still remain in file named 'game' not be suffix
> '.log'.
>
>
> my question is how to create new log files on an hourly not depend on new
> byte stream log appended.
>
>
> yours
> Allen