PDA

View Full Version : Resin Logging setting


jamesmedlycott
06-25-2010, 10:02 AM
Hi,

We are looking to try and format our logging.

I have 2 seperate questions:

1) we would like to put a seperator in between the log columns
ie date | severity | msg

2) After the above, how will this handle multi line errors like stack dumps etc?

Thanks
James

emil
06-25-2010, 05:55 PM
Hi James,

You can change the logging timestamp and format using the <log-handler> tag:


<log-handler name="" level="all" path="stdout:"
timestamp="[%y-%m-%d %H:%M:%S.%s]"
format=" | ${log.level} | ${log.message} "/>


The timestamp will appear before the format.

Multi-line logs will still have line break, though. If it helps with your parsing, you can also put a character at the start of a new record by setting the timestamp like:


<log-handler name="" level="all" path="stdout:"
timestamp="> [%y-%m-%d %H:%M:%S.%s]"
format=" | ${log.level} | ${log.message} "/>


Better yet, you could create a custom Java logging handler. There's an example here:

http://caucho.com/resin-4.0/admin/logging.xtp#custom%20handler

Best,
Emil

jamesmedlycott
06-28-2010, 08:16 AM
I like the idea of having the seperator, but 2 further questions:

Would the date then appear on everyline of the multi line msg?
Where do I add the format line?
we have the logging level set outside any sections.
we have archiving/timestamp format set within a host.


in the host we have

<stdout-log path="${resin.root}/logs/${server.id}_out.log" timestamp="[%d-%b-%Y %H:%M:%S] ">
<rollover-size>120mb</rollover-size>
<rollover-period>1D</rollover-period>
<archive-format>archive/${server.id}_out_%Y-%m-%d.log.gz</archive-format>


so I was thinking of changing it to

<stdout-log path="${resin.root}/logs/${server.id}_out.log" timestamp="[%d-%b-%Y %H:%M:%S] ">
<rollover-size>120mb</rollover-size>
<rollover-period>1D</rollover-period>
<archive-format>archive/${server.id}_out_%Y-%m-%d.log.gz</archive-format>
format=" | ${log.level} | ${log.message} "


We are on resin 3.1