You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Pradeep Kumar PALAPARTHY <p....@gmail.com> on 2008/06/09 11:57:02 UTC
Log Corruption
Hi,
I have a multi threaded application.
There are multiple task getting created in the application which will log to
a separate log file.
*For each task the log file initialization happens in AbstractTaskComponent
as follows:*
// get the log directory
File taskLogDir =
TaskControllerComponent.getTaskControllerComponent().getTaskLogDirectory();
File taskLogFile = new File( taskLogDir, task.getTskId() + ".log" );
taskLogRejectedFile = new File( taskLogDir, task.getTskId() +
".rejected.rawrecord.log" );
// add a special appender for placing this task's log messages in
its own file
// get the log level of the main logger
Logger rootLogger = LogManager.getRootLogger();
// the custom appender for this task logger
FileAppender appender = null;
try
{
appender = new FileAppender( new PatternLayout( "%m%n" ),
taskLogFile.getAbsolutePath() );
}
catch ( IOException e )
{
log.error( "Error adding custom log appender for task logging",
e );
}
// filter log messages to this appender by only printing messages
generated by threads belonging to the
// same thread group as the main thread, if the thread's group is
the main group then just log
// messages from this thread
if ( runner.getThreadGroup().getParent() != null )
{
appender.addFilter( new ThreadGroupFilter(
runner.getThreadGroup() ) );
}
else
{
appender.addFilter( new ThreadFilter( runner ) );
}
rootLogger.addAppender( appender );
*
Also the logger configuration happens at one time while initiating the
application as follows:*
// get the logging configuration file - must exist
URL logURL = getClass().getResource( "/log4j_server.properties" );
if ( logURL == null )
{
System.out.println( "Could not find log4j_server.properties log
configuration file" );
return;
}
// initialise the logging framework
PropertyConfigurator.configure( logURL );
* The properties set in log4j_server.properties as follows:
*
# general program output:
log4j.rootCategory=INFO,stdout,alog
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%c] [%t] (%F:%L) - %m%n
# access log output:
log4j.appender.alog=org.apache.log4j.FileAppender
log4j.appender.alog.file=server.log
log4j.appender.alog.append=false
log4j.appender.alog.layout=org.apache.log4j.PatternLayout
log4j.appender.alog.layout.ConversionPattern=%5p [%c] [%t] (%F:%L) - %m%n
log4j.logger.com.azure=TRACE
log4j.logger.net.sf.hibernate=INFO*
Still some times the log getting mixed up(one task log in another task file)
*. But this happens once in a while
I was unable to find in what scenario it is going wrong.
Any help would be appreciated.
Regards,
Pradeep
Re: Log Corruption
Posted by Pradeep Kumar PALAPARTHY <p....@gmail.com>.
Hi Arnold,
Thanks for the response. Yaa you are right I have sent it to a wrong mailing
list.
Regards,
Pradeep
On Tue, Jun 17, 2008 at 9:41 PM, Curt Arnold <ca...@apache.org> wrote:
>
> On Jun 9, 2008, at 4:57 AM, Pradeep Kumar PALAPARTHY wrote:
>
> Hi,
>>
>> I have a multi threaded application.
>> There are multiple task getting created in the application which will log
>> to a separate log file.
>>
>> For each task the log file initialization happens in AbstractTaskComponent
>> as follows:
>>
>> // get the log directory
>> File taskLogDir =
>> TaskControllerComponent.getTaskControllerComponent().getTaskLogDirectory();
>> File taskLogFile = new File( taskLogDir, task.getTskId() + ".log"
>> );
>> taskLogRejectedFile = new File( taskLogDir, task.getTskId() +
>> ".rejected.rawrecord.log" );
>>
>>
> ...
>
>>
>> Still some times the log getting mixed up(one task log in another task
>> file). But this happens once in a while
>>
>> I was unable to find in what scenario it is going wrong.
>>
>> Any help would be appreciated.
>>
>> Regards,
>> Pradeep
>>
>>
> Hope you have found the problem in the interim. Your example appears to be
> Java but you posted to the log4cxx-user mailing list. You may have better
> luck if post to the log4j-user mailing list. However there isn't enough to
> reproduce your problem since you do not provide the code for ThreadFilter or
> ThreadGroupFilter which are likely suspects. If they happen to return
> NEUTRAL, you may need either to add a final DenyAllFilter to finally reject
> all events that were not explicitly matched by earlier filters.
>
Re: Log Corruption
Posted by Curt Arnold <ca...@apache.org>.
On Jun 9, 2008, at 4:57 AM, Pradeep Kumar PALAPARTHY wrote:
> Hi,
>
> I have a multi threaded application.
> There are multiple task getting created in the application which
> will log to a separate log file.
>
> For each task the log file initialization happens in
> AbstractTaskComponent as follows:
>
> // get the log directory
> File taskLogDir =
> TaskControllerComponent
> .getTaskControllerComponent().getTaskLogDirectory();
> File taskLogFile = new File( taskLogDir, task.getTskId() +
> ".log" );
> taskLogRejectedFile = new File( taskLogDir, task.getTskId()
> + ".rejected.rawrecord.log" );
>
...
>
> Still some times the log getting mixed up(one task log in another
> task file). But this happens once in a while
>
> I was unable to find in what scenario it is going wrong.
>
> Any help would be appreciated.
>
> Regards,
> Pradeep
>
Hope you have found the problem in the interim. Your example appears
to be Java but you posted to the log4cxx-user mailing list. You may
have better luck if post to the log4j-user mailing list. However
there isn't enough to reproduce your problem since you do not provide
the code for ThreadFilter or ThreadGroupFilter which are likely
suspects. If they happen to return NEUTRAL, you may need either to
add a final DenyAllFilter to finally reject all events that were not
explicitly matched by earlier filters.