<!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>
&nbsp; &lt;conversionRule conversionWord="bundlemarker"<br>
&nbsp; &nbsp;&nbsp;&nbsp;
converterClass="org.ekkehard.logback.util.BundleMarkerConverter"/&gt;<br>
...<br>
<br>
&nbsp; &lt;appender name="STDOUT"<br>
&nbsp;&nbsp;&nbsp; class="ch.qos.logback.core.ConsoleAppender"&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;layout class="ch.qos.logback.classic.PatternLayout"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Pattern&gt;%d{HH:mm:ss.SSS} %-5level [%logger{40}]
%bundlemarker %msg%n&lt;/Pattern&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/layout&gt;<br>
&nbsp; &lt;/appender&gt;<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&amp;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:

   &lt;conversionRule conversionWord="myMarker"
            converterClass="de.gentz-software.logback.MyMarkerConverter"/&gt;

Here is a sample config file:

&lt;configuration&gt;
   &lt;conversionRule conversionWord="myMarker"
           converterClass="de.gentz-software.logback.MyMarkerConverter" /&gt;
        
   &lt;appender name="STDOUT"
     class="ch.qos.logback.core.ConsoleAppender"&gt;
     &lt;layout class="ch.qos.logback.classic.PatternLayout"&gt;
       &lt;Pattern&gt;%-4relative [%thread] %myMarker - %msg%n&lt;/Pattern&gt;
     &lt;/layout&gt;
   &lt;/appender&gt;

   &lt;root&gt;
     &lt;level value="debug" /&gt;
     &lt;appender-ref ref="STDOUT" /&gt;
   &lt;/root&gt;
&lt;/configuration&gt;


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>