How can I make log4perl output easier to read?

When using log4perl, the debug log layout that I'm using is :

log4perl.appender.D10.layout=PatternLayout
log4perl.appender.D10.layout.ConversionPattern=%d [pid=%P] %p %F{1} (%L) %M %m%n
log4perl.appender.D10.Filter = DebugAndUp

This produces very verbose debug logs, for example:

2008/11/26 11:57:28 [pid=25485] DEBUG SomeModule.pm (331) functions::SomeModule::Test Test XXX was successfull
2008/11/26 11:57:29 [pid=25485] ERROR SomeOtherUnrelatedModule.pm (99999) functions::SomeModule::AnotherTest AnotherTest YYY has faled

This works great, and provides excellent debugging data.

However, each line of the debug log contains different function names, pid length, etc. This makes each line layout differently, and makes reading debug logs much harder than it needs to be.

Is there a way in log4perl to format the line so that the debugging metadata (everything up until the actual log message) be padded at the end with spaces/tabs, and have the actual message start at the same column of text?

Answers


You can pad the single fields that make up your entries. For example [pid=%5P] will always give you at least 5 characters for the PID.

The "Quantify Placeholders" section in the docs for Log::Log4perl::Layout gives more details.


Need Your Help

Id in TagSupport

java jsp servlets

When creating JSP-Tags I create sometimes an attribute "id" to set the element-id of the element created. For that id I also create a setter. Now I've found out that TagSupport already has an attri...

Stopping modal when window is closed (Cocoa)

cocoa modal-dialog nswindow

I am currently displaying a modal window by using this code:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.