Logging to the Event Log

Monday, March 24, 2008 0 Comments

By default Plastic server logs both activity and errors to a file (loader.log.txt) located at the server's installation directory.

Since Plastic uses log4net as logging mechanism, it is very flexible to customize logging messages and output.

The following script shows how to configure the log (editing loader.log.conf at server's directory) to output errors to the Windows Event Log.

<log4net>

<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message%newline" />
</layout>
</appender>

<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="loader.log.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message%newline" />
</layout>
</appender>

<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
<threshold value="ERROR" />
<applicationName value="Plastic Server" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message%newline" />
</layout>
</appender>


<logger name="UpdatePerf">
<level value="INFO" />
</logger>

<logger name="Transaction">
<level value="INFO" />
</logger>

<logger name="Operations">
<level value="INFO" />
</logger>

<root>
<level value="ERROR" />
<appender-ref ref="FileAppender" />
<appender-ref ref="EventLogAppender" />
</root>


</log4net>


The sample also shows how to configure Plastic logging to work with selected sources. In this case we're selecting all the transaction, performance and operations sources.

We normally use the following conversionpattern to define appenders:

%date %thread %property{UserID} %property{TransactionID}
%property{ClientMachine} %-5level %logger -

We develop Plastic SCM, a version control that excels in branching and merging, can deal with huge projects and big binary assets natively, and it comes with GUIs and tools to make everything simpler.

If you want to give it a try, download it from here.

We are also the developers of SemanticMerge, and the gmaster Git client.

0 comentarios: