logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joachim Kanbach" <jo...@gmx.de>
Subject RoutingAppender with parameterized pattern/nested RollingFileAppender/evaluateOnStartup
Date Tue, 18 Jul 2017 14:42:08 GMT
Hi all,

I'm using a configuration with two nested RoutingAppenders like this:

<Routing name="ApplicationRouting">
  <Routes pattern="$${ctx:applicationName}">
    <Route key="SomeApplication">
      <Routing name="ThreadRouting">
        <Routes pattern="$${ctx:threadId}">
            <RollingFile name="SomeApplicationLog"
                    <CronTriggeringPolicy schedule="0 0 0 * * ?" evaluateOnStartup="true"/>

So the idea is to split log files for different applications running on this Payara instance
(hence the com.sun.aas.instanceRoot references), and then again for different processing threads.

This works all nicely, including rollover. The only thing that doesn't work, and I'm not surprised
by that, is the evaluateOnStartup attribute. Due to the dynamic patterns, Log4j obviously
has no chance of knowing which files to rollover if the JVM is restarted. As long as it keeps
running, the appenders apparently keep track of those files and therefore perform the rollover.

Another related issue is that even for files that would not need to be rolled over on startup
because they were modified on the same day still, those files that don't get written to again
after startup will also not be picked up by the next rollover. Again, Log4j can't know about
those files.

As for files that would need to be rolled on startup; I could write some application code
that scans for files matching my expected pattern(s) and simulates the rollover. But in the
second case, it appears to me that I would need to use some tricks like triggering output
to all log files in order to make them "known" to the Log4j appenders.

Has anyone found an elegant solution to this?

Best regards,
Joachim Kanbach

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

View raw message