<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ceki,<br>
<br>
just tried my custom MarkerConverter<br>
<br>
but I got an error:<br>
<br>
ERROR in ch.qos.logback.core.pattern.parser.Compiler@26312 -
[bundlemarker] is not a valid conversion word<br>
<br>
---------<br>
from my config file:<br>
<br>
...<br>
<conversionRule conversionWord="bundlemarker"<br>
converterClass="org.ekkehard.logback.util.BundleMarkerConverter"/><br>
...<br>
<br>
<appender name="STDOUT"<br>
class="ch.qos.logback.core.ConsoleAppender"><br>
<layout class="ch.qos.logback.classic.PatternLayout"><br>
<Pattern>%d{HH:mm:ss.SSS} %-5level [%logger{40}]
%bundlemarker %msg%n</Pattern><br>
</layout><br>
</appender><br>
<br>
-----<br>
perhaps the problem is that my BundleMarkerConverter class was not
found -<br>
all runs under OSGI<br>
<br>
what do you think - should I add the import to logback core or logback
classic ?<br>
or could something else be wrong because the error notes that the
conversion word wasn't valid<br>
and not that class BundleMarkerConverter wasn't found<br>
<br>
thanks<br>
<br>
ekke<br>
<br>
ekkehard schrieb:
<blockquote cite="mid:48F4CD5A.10500@gentz-software.de" type="cite">
<pre wrap="">Ceki Gulcu schrieb:
</pre>
<blockquote type="cite">
<pre wrap="">Hi Ekke,
Here is the code for MarkerConverter:
======= Start MarkerConverter.hava ========
package ch.qos.logback.classic.pattern;
import org.slf4j.Marker;
import ch.qos.logback.classic.spi.LoggingEvent;
/**
* Return the event's marker value(s).
*
* @author S&eacute;bastien Pennec
*/
public class MarkerConverter extends ClassicConverter {
private static String EMPTY = "";
public String convert(LoggingEvent le) {
Marker marker = le.getMarker();
if (marker == null) {
return EMPTY;
} else {
return marker.toString();
}
}
}
======= End MarkerConverter.hava ========
Studying the code above, I would say that you have two options. First,
just remove the [] from the conversion pattern. So instead of writing
"%d %level [%marker] - %msg%n"
as you conversion pattern, just write
"%d %level %marker - %msg%n"
You second option is to write your own converter for handling
markers. You could modify it to return an empty string if there is no
marker, and to return "["+marker.toString()+"]" if there is a marker
in the event. Here is sample code:
package de.gentz-software.logback;
import org.slf4j.Marker;
import ch.qos.logback.classic.spi.LoggingEvent;
public class MyMarkerConverter extends ClassicConverter {
private static String EMPTY = "";
public String convert(LoggingEvent le) {
Marker marker = le.getMarker();
if (marker == null) {
return EMPTY;
} else {
return "["+marker.toString()+"]";
}
}
}
You also need to let logback know about your conversion word. Here is
how:
<conversionRule conversionWord="myMarker"
converterClass="de.gentz-software.logback.MyMarkerConverter"/>
Here is a sample config file:
<configuration>
<conversionRule conversionWord="myMarker"
converterClass="de.gentz-software.logback.MyMarkerConverter" />
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%-4relative [%thread] %myMarker - %msg%n</Pattern>
</layout>
</appender>
<root>
<level value="debug" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
I hope this helps,
</pre>
</blockquote>
<pre wrap=""><!---->
of course - thanks :-)
...gives me some more ideas how to solve it best to print OSGI
bundle-name and service-name
I put into the Marker-tree
ekke
_______________________________________________
Logback-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Logback-user@qos.ch">Logback-user@qos.ch</a>
<a class="moz-txt-link-freetext" href="http://qos.ch/mailman/listinfo/logback-user">http://qos.ch/mailman/listinfo/logback-user</a>
</pre>
</blockquote>
<br>
<br>
<div class="moz-signature"><br>
</div>
</body>
</html>