
Hi César, My response is inline. On 27.12.2011 10:19, César Álvarez Núñez wrote:
Hi all,
Our application makes an intensive use of Profiler (http://www.slf4j.org/extensions.html#profiler). It has been very useful during the development stage an we would like to keep it at production stage but there is a problem since its "log level" is hard-coded to "debug".
Currently the profiler use the same application class logger so if log level is set to "info" in our production environment we lose the "profiler" log :-(
Alternatives:
* Use different loggers for application and profiler >-->> It requires to refactoring all the code and remember that any new Profiler that will be used need to set a custom logger instead of the default class logger.
* Open a request to modify Profiler in order to set a custom log level.
This makes sense. See first if the TurboFilter described below approach works for you. Otherwise, please file a bug report requesting for this feature.
* Keep minimum log level to "debug" and make use of a Filter to accept any log event with marker=PROFILER, otherwise only accept if log level >= INFO >-->> It only will work with LogBack but Profiler belongs to SLF4J so it should work with any bridge.
Have you considered using a TurboFilter [1]? Here is a TurboFilter which will enable profiler logs for all logging levels. import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.turbo.TurboFilter; import ch.qos.logback.core.spi.FilterReply; import org.slf4j.Marker; import org.slf4j.MarkerFactory; public class ProfilingEnabler extends TurboFilter { Marker profilerMarker = MarkerFactory.getMarker(Profiler.PROFILER_MARKER_NAME); @Override public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t){ if(marker == profilerMarker) return FilterReply.ACCEPT; else return FilterReply.NEUTRAL; } } [1] http://logback.qos.ch/manual/filters.html#TurboFilter
/César.
Cheers, -- Ceki http://twitter.com/#!/ceki