logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: New log file does not get created when old log file deleted in case of TCPSocketServer
Date Fri, 01 Sep 2017 03:52:51 GMT
Hello Anhad,

Are you saying that the log file is deleted externally to the JVM writing
it? For example, a user or another program deletes the log file?

Do you see any errors on the console that might be logged by the internal
Log4j status logger?

Also, are we talking about the active file managed by the file appender? I
am surprised that the file is not locked.

Gary

On Thu, Aug 31, 2017 at 1:03 PM, Anhad Singh Bhasin <anhadbhasin@gmail.com>
wrote:

> Hello All,
>
> Great to see Log4j 2.9.0 release. Thanks to all the contributors.
>
> I have TCPSocketServer running on Edge node of a cluster and all other data
> nodes send log events to the TCPSocketServer running on edge node. And I am
> using standard routing to redirect log events to individual log files.
>
> <Route>
>       <RollingFile name="WorkerFile" fileName="/opt//logs/${ctx:
> logId}.log"
> filePattern="/opt/logs/${ctx:logId}-%i.log">
>         <PatternLayout>
>           <pattern>%d{ISO8601} [%t] %p %c{3} - %m%n</pattern>
>         </PatternLayout>
>         <Policies>
>           <SizeBasedTriggeringPolicy size="100 MB" />
>         </Policies>
>       </RollingFile>
> </Route>
>
> ** Full configurations are below **
>
> The Routing creates a new log file for each of the context first time the
> log event for that context is sent and log events received by the server
> are recorded into their appropriate log files. The problem occurs when one
> of the log file is deleted. If one of the log file is deleted, the new log
> events corresponding to that context are lost and no new file gets created.
> The work around is to restart the TCPSocketServer. After the restart, a new
> log file gets created again and then all the log events gets recorded
> appropriately. I am trying to find out if there is a way the log events
> create a new file if the old log file is deleted somehow.
>
> Any suggestions, comments would be deeply appreciated.
>
> Thanks for your time.
> Regards,
> Anhad Singh Bhasin
>
>
>
> *log4j2.xml *
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="TRACE" name="XLogging" monitorInterval="30">
>   <Appenders>
>     <Socket name="XSocket" host="X" port="5235" >
>       <SerializedLayout />
>     </Socket>
>     <Async name="AsyncFile">
>       <AppenderRef ref="XSocket"/>
>     </Async>
>     </Appenders>
>   <Loggers>
>     <Root level="WARN">
>       <AppenderRef ref="AsyncFile"/>
>     </Root>
>     <AsyncLogger name="org.reflections.Reflections" level="ERROR" />
>     <AsyncLogger name="org.apache.hadoop" level="INFO" />
>     <AsyncLogger name="com.X" level="DEBUG" />
>   </Loggers>
> </Configuration>
>
>
> *log4j2-server.xml *
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="TRACE" name="XLogging" monitorInterval="30">
>   <Appenders>
>     <Routing name="Routing">
>     <Routes pattern="$${ctx:logId}">
> <Route>
>       <RollingFile name="XWorkerFile" fileName="/opt/logs/${ctx:
> logId}.log"
> filePattern="/opt/logs/${ctx:logId}-%i.log">
>         <PatternLayout>
>           <pattern>%d{ISO8601} [%t] %p %c{3} - %m%n</pattern>
>         </PatternLayout>
>         <Policies>
>           <SizeBasedTriggeringPolicy size="1 MB" />
>         </Policies>
>       </RollingFile>
>     </Route>
> </Routes>
>     </Routing>
>     <Async name="AsyncFile">
>         <AppenderRef ref="Routing" />
>     </Async>
>   </Appenders>
>   <Loggers>
>     <Root level="WARN">
>       <AppenderRef ref="AsyncFile"/>
>     </Root>
>     <AsyncLogger name="org.reflections.Reflections" level="ERROR" />
>     <AsyncLogger name="org.apache.hadoop" level="INFO" />
>     <AsyncLogger name="com.X" level="DEBUG" />
>   </Loggers>
> </Configuration>
>

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