[jboss-as7-dev] logger config per deployment / app

James Perkins jperkins at redhat.com
Mon Jun 4 11:57:38 EDT 2012


On 06/04/2012 06:24 AM, Ales Justin wrote:
>> Only if you add a logging.properties file to your deployment. Once you
>> do that though, you can no longer configure it via the management console.
> Hmmm, does this only disable handling via management console,
> or does it completely disable whatever you setup via CustomHandlerService and/or LoggerHandlerService?
It disables only configuration via the subsystem management in general. 
You can't make changes from the management console or via services as a 
base logging configuration as no concept of services.
> We add our own handler to ROOT
>
>          final CustomHandlerService chs = new CustomHandlerService(Logger.class.getName(), "org.jboss.as.capedwarf");
>          chs.setFormatterSpec(new FormatterSpec() {
>              public void apply(Handler handler) {
>              }
>          });
>          final String capedwarfLogger = Constants.CAPEDWARF.toUpperCase();
>          final ServiceName chsName = LogServices.handlerName(capedwarfLogger);
>          final ServiceBuilder<Handler>  chsBuilder = serviceTarget.addService(chsName, chs);
>          newControllers.add(chsBuilder.setInitialMode(ServiceController.Mode.ON_DEMAND).install());
>
>          final String rootLogger = "ROOT";
>          final LoggerHandlerService lhs = new LoggerHandlerService(rootLogger);
>          final ServiceBuilder<org.jboss.logmanager.Logger>  lhsBuilder = serviceTarget.addService(LogServices.loggerHandlerName(rootLogger, capedwarfLogger), lhs);
>          lhsBuilder.addDependency(LogServices.loggerName(rootLogger));
>          lhsBuilder.addDependency(chsName, Handler.class, lhs.getHandlerInjector());
>          newControllers.add(lhsBuilder.setInitialMode(ServiceController.Mode.ON_DEMAND).install());
>
> [X] But we also setup -- similar to existing LoggingConfigurationProcessor -- our own LogContext,
> if the app explicitly enables it -- via some config property and log.props file.
>
> The problem is, if we have [X] use case, our handler from the code above never gets used / hit.
> Any idea why?
Each LogContext is like a clean slate. When a logging configuration is 
found in a deployment via the LoggingConfigurationProcessor a new 
LogContext is created and either log4j's Log Manager or JBoss Log 
Manager is invoked to configure the log context. The new LogContext does 
not inherit any configuration from any other LogContext.
>> I was working on a concept of logging profiles that could be assigned to
>> deployments. Though that would still require a change to the deployment.
>> It could be interesting to isolate all deployment logging on-demand. Not
>> quite sure how it would work, but I could see it being useful for debugging.
>>
>> On 05/24/2012 03:00 PM, Ales Justin wrote:
>>> Can you already configure loggers per deployment?
>>> e.g. I want org.hibernate.search at trace for my app, but not for the whole AS
>>>
>>> If yes, how?
>>>
>>> I mean, is there a better way than adding the old TCCL filter hack I once helped to write. :)

-- 
James R. Perkins
JBoss by Red Hat



More information about the jboss-as7-dev mailing list