Re: Custom ConfigurationFactory not loaded

2014-08-01 Thread Clément Guillaume
PluginManager.addPackage(“com.myorg.mypackage”) works with trunk ! But for
me it is almost the same as setting the system property.
I would love that it automatically find my ConfigurationFactory. Is it a
bug?

Clément


On Fri, Aug 1, 2014 at 11:02 AM, Remko Popma  wrote:

> The packages attribute in configuration (and the corresponding
> PluginManager.addPackage method) does not work in 2.0.
>
> This has been fixed in trunk and the fix will be in the upcoming 2.0.1
> release.
> Can you try with trunk?
>
>
> On Sat, Aug 2, 2014 at 2:05 AM, Clément Guillaume 
> wrote:
>
> > The fact is that the method getSupportedTypes() is never called ! (It's
> > return a custom extension: ".myorg")
> > I'm using 2.0. And even a call to
> > PluginManager.addPackage(“com.myorg.mypackage”)
> > doesn't works.
> >
> > Clément
> >
> >
> > On Thu, Jul 31, 2014 at 10:31 PM, Ralph Goers <
> ralph.go...@dslextreme.com>
> > wrote:
> >
> > > It also occurs to me that the plugin manager may not be finding the
> > > plugin.  If you are using 2.0 then I believe the annotation processor
> > > should register the factory as a plugin automatically. If you are using
> > an
> > > older release you might have been required to call
> > > PluginManager.addPackage(“com.myorg.mypackage”) to have the plugin
> > manager
> > > search for your plugin.
> > >
> > > Ralph
> > >
> > > On Jul 31, 2014, at 10:26 PM, Ralph Goers 
> > > wrote:
> > >
> > > > Your annotations are correct. However, in the code snippet below you
> > > don’t show what getSupportedTypes() returns. The generic
> > > ConfigurationFactory inspects all the ConfigurationFactory plugins
> using
> > > the order to determine which should be inspected first, second, etc.
>  It
> > > calls getSupportedTypes to find out what file extensions the
> > > ConfigurationFactory handles. If the provided configuration file
> matches
> > > one of the file extensions than that factory will be used.  “*” is used
> > as
> > > a wildcard to specify that it handles any file extension (which is what
> > the
> > > XMLConfigurationFactory does).  However, with an Order of 10 if you
> > > specified a “*” I believe your factory would have to handle XML, JSON
> and
> > > YAML configurations.
> > > >
> > > > I would suggest having getSupportedTypes return something like “.cfg”
> > > and then having your configuration files end with .cfg.
> > > >
> > > > Ralph
> > > >
> > > > On Jul 31, 2014, at 6:18 PM, Clément Guillaume <
> cguilla...@hotpads.com
> > >
> > > wrote:
> > > >
> > > >> Hi,
> > > >>
> > > >> I'm trying to use a custom ConfigurationFactory. I created and
> > > annotated it
> > > >> with a @Plugin and an @Order like this:
> > > >>
> > > >> @Plugin(category = "ConfigurationFactory", name =
> > > >> "StartupConfigurationFactory")
> > > >> @Order(10)
> > > >> public class StartupConfigurationFactory extends
> ConfigurationFactory{
> > > >> ...
> > > >> }
> > > >>
> > > >> But it is never loaded (none of the 2 methods are called).
> > > >>
> > > >> If I specify the system property "log4j.configurationFactory" with
> the
> > > name
> > > >> of my class before creating a logger, my factory is successfully
> > loaded.
> > > >>
> > > >> Did I made a mistake declaring my ConfigurationFactory ?
> > > >>
> > > >> Clément
> > > >
> > >
> > >
> > > -
> > > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> > >
> > >
> >
>


Re: problems with web app and JndiContextSelector

2014-08-01 Thread Mike Calmus
We're using a Servlet 2.5 container and configuration. I added the
Log4jContextSelector environment variable to the container startup as well
as loading all the Log4j 2.0 jars with the container. I added the following
items to my web.xml:

  
isLog4jContextSelectorNamed
true
  
  
log4jContextName
myapp
  
  
log4jConfiguration

file:///${sys:projectprops}/myapp/default/log4j2.xml
  
  

org.apache.logging.log4j.web.Log4jServletContextListener
  
  
log4jServletFilter

org.apache.logging.log4j.web.Log4jServletFilter
  
  
log4jServletFilter
/*
REQUEST
FORWARD
INCLUDE
ERROR
  
With just this, logging works fine, but I get an error when the JNDI lookup
fails.

  
Sets the logging context for the web-app
log4j/context-name
java.lang.String
myapp
  
The JNDI lookup error goes away but logging stops working.

I also tried adding the following with no change in results.

  
URL for configuring log4j context
log4j/configuration-resource
java.lang.String

file:///${sys:projectprops}/myapp/default/log4j2.xml
  


On Tue, Jul 29, 2014 at 11:37 AM, Ralph Goers 
wrote:

> The best would be a sample project that demonstrates the problem. At a
> minimum I would think the web.xml and log4j 2 configuration.
>
> Ralph
>
> On Jul 29, 2014, at 5:47 AM, Mike Calmus  wrote:
>
> > I am having problems moving our web app over to Log4j 2.0 using JNDI
> > lookups. I followed the configuration documentation and am not getting
> any
> > errors, but nothing is being logged to my configured appenders. Weirdly,
> if
> > I remove the JNDI env-entry configuration from web.xml logging seems to
> > work, albeit with the expected NameNotFoundException in the server
> output.
> >
> > One possibly relevant configuration difference is that we load the log4j
> > jar files as part of server startup so each app doesn't have to load
> them.
> >
> > Any ideas? What configuration can I provide to help troubleshoot?
> >
> > Thanks.
>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


Re: Custom ConfigurationFactory not loaded

2014-08-01 Thread Remko Popma
The packages attribute in configuration (and the corresponding
PluginManager.addPackage method) does not work in 2.0.

This has been fixed in trunk and the fix will be in the upcoming 2.0.1
release.
Can you try with trunk?


On Sat, Aug 2, 2014 at 2:05 AM, Clément Guillaume 
wrote:

> The fact is that the method getSupportedTypes() is never called ! (It's
> return a custom extension: ".myorg")
> I'm using 2.0. And even a call to
> PluginManager.addPackage(“com.myorg.mypackage”)
> doesn't works.
>
> Clément
>
>
> On Thu, Jul 31, 2014 at 10:31 PM, Ralph Goers 
> wrote:
>
> > It also occurs to me that the plugin manager may not be finding the
> > plugin.  If you are using 2.0 then I believe the annotation processor
> > should register the factory as a plugin automatically. If you are using
> an
> > older release you might have been required to call
> > PluginManager.addPackage(“com.myorg.mypackage”) to have the plugin
> manager
> > search for your plugin.
> >
> > Ralph
> >
> > On Jul 31, 2014, at 10:26 PM, Ralph Goers 
> > wrote:
> >
> > > Your annotations are correct. However, in the code snippet below you
> > don’t show what getSupportedTypes() returns. The generic
> > ConfigurationFactory inspects all the ConfigurationFactory plugins using
> > the order to determine which should be inspected first, second, etc.  It
> > calls getSupportedTypes to find out what file extensions the
> > ConfigurationFactory handles. If the provided configuration file matches
> > one of the file extensions than that factory will be used.  “*” is used
> as
> > a wildcard to specify that it handles any file extension (which is what
> the
> > XMLConfigurationFactory does).  However, with an Order of 10 if you
> > specified a “*” I believe your factory would have to handle XML, JSON and
> > YAML configurations.
> > >
> > > I would suggest having getSupportedTypes return something like “.cfg”
> > and then having your configuration files end with .cfg.
> > >
> > > Ralph
> > >
> > > On Jul 31, 2014, at 6:18 PM, Clément Guillaume  >
> > wrote:
> > >
> > >> Hi,
> > >>
> > >> I'm trying to use a custom ConfigurationFactory. I created and
> > annotated it
> > >> with a @Plugin and an @Order like this:
> > >>
> > >> @Plugin(category = "ConfigurationFactory", name =
> > >> "StartupConfigurationFactory")
> > >> @Order(10)
> > >> public class StartupConfigurationFactory extends ConfigurationFactory{
> > >> ...
> > >> }
> > >>
> > >> But it is never loaded (none of the 2 methods are called).
> > >>
> > >> If I specify the system property "log4j.configurationFactory" with the
> > name
> > >> of my class before creating a logger, my factory is successfully
> loaded.
> > >>
> > >> Did I made a mistake declaring my ConfigurationFactory ?
> > >>
> > >> Clément
> > >
> >
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
>


Re: Custom ConfigurationFactory not loaded

2014-08-01 Thread Clément Guillaume
The fact is that the method getSupportedTypes() is never called ! (It's
return a custom extension: ".myorg")
I'm using 2.0. And even a call to
PluginManager.addPackage(“com.myorg.mypackage”)
doesn't works.

Clément


On Thu, Jul 31, 2014 at 10:31 PM, Ralph Goers 
wrote:

> It also occurs to me that the plugin manager may not be finding the
> plugin.  If you are using 2.0 then I believe the annotation processor
> should register the factory as a plugin automatically. If you are using an
> older release you might have been required to call
> PluginManager.addPackage(“com.myorg.mypackage”) to have the plugin manager
> search for your plugin.
>
> Ralph
>
> On Jul 31, 2014, at 10:26 PM, Ralph Goers 
> wrote:
>
> > Your annotations are correct. However, in the code snippet below you
> don’t show what getSupportedTypes() returns. The generic
> ConfigurationFactory inspects all the ConfigurationFactory plugins using
> the order to determine which should be inspected first, second, etc.  It
> calls getSupportedTypes to find out what file extensions the
> ConfigurationFactory handles. If the provided configuration file matches
> one of the file extensions than that factory will be used.  “*” is used as
> a wildcard to specify that it handles any file extension (which is what the
> XMLConfigurationFactory does).  However, with an Order of 10 if you
> specified a “*” I believe your factory would have to handle XML, JSON and
> YAML configurations.
> >
> > I would suggest having getSupportedTypes return something like “.cfg”
> and then having your configuration files end with .cfg.
> >
> > Ralph
> >
> > On Jul 31, 2014, at 6:18 PM, Clément Guillaume 
> wrote:
> >
> >> Hi,
> >>
> >> I'm trying to use a custom ConfigurationFactory. I created and
> annotated it
> >> with a @Plugin and an @Order like this:
> >>
> >> @Plugin(category = "ConfigurationFactory", name =
> >> "StartupConfigurationFactory")
> >> @Order(10)
> >> public class StartupConfigurationFactory extends ConfigurationFactory{
> >> ...
> >> }
> >>
> >> But it is never loaded (none of the 2 methods are called).
> >>
> >> If I specify the system property "log4j.configurationFactory" with the
> name
> >> of my class before creating a logger, my factory is successfully loaded.
> >>
> >> Did I made a mistake declaring my ConfigurationFactory ?
> >>
> >> Clément
> >
>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


Re: log4j 2.0 - About StatusLogger logging level and console output

2014-08-01 Thread Remko Popma
Ok. Take a look at the system properties section of the Configuration manual 
page. There seem to be two settings. I'm not sure which to use: 
Log4jDefaultStatusLevel or log4j2.StatusLogger.level. 

Sent from my iPhone

> On 2014/08/01, at 16:15, Marco Cosentino  wrote:
> 
> Hi Remko,
> thanks for the reply.
> I'd still like something which can be enabled through system preoperties and 
> logs at very early stages, for example, where the config is read from.
> 
> Marco.
> 
>> On 08/01/2014 12:04 AM, Remko Popma wrote:
>> All you need to do is set status="trace" in your log4j2.xml config file.
>> 
>> So the beginning of your config looks like this:
>> > 
>> Sent from my iPhone
>> 
>>> On 2014/08/01, at 1:13, Marco Cosentino  wrote:
>>> 
>>> Hi,
>>> I'm trying to get log4j 2.0 debug information printed out in the console 
>>> but I couldn't manage to get them.
>>> In log4j 1.x you would set the system property "log4j.debug".
>>> 
>>> I thought that the mechanism was similar in log4j 2.x and apparently it 
>>> should be by setting
>>> log4j2.StatusLogger.level=DEBUG
>>> 
>>> Still nothing, so I dug a little bit in the code and found that the 
>>> StatusLogger logs its messages either to the listeners (if there's at least 
>>> one) or to a SimpleLogger (logger) which is initialized in the constructor 
>>> (method StatusLogger#logMessage()).
>>> 
>>> I found that there was a JMX listener registered so I disabled JMX beans 
>>> with
>>> log4j2.disable.jmx=true
>>> but still no luck: the messages don't appear in the console.
>>> 
>>> I noticed though that the constructor might be the source of the problem:
>>> 
>>>private StatusLogger() {
>>>this.logger = new SimpleLogger("StatusLogger", Level.ERROR, false, 
>>> true, false, false, Strings.EMPTY, null, PROPS,
>>>System.err);
>>>this.listenersLevel = Level.toLevel(DEFAULT_STATUS_LEVEL, 
>>> Level.WARN).intLevel();
>>>}
>>> 
>>> The SimpleLogger is initialized using level ERROR therefore the isEnabled 
>>> implementation in StatusLogger returns the logging level of this.logger 
>>> which is always ERROR even if I wanted DEBUG.
>>> 
>>> Would it make sense to use DEFAULT_STATUS_LEVEL to actually set the level 
>>> into the SimpleLogger constructor?
>>> Why is it so hard to get debug messages showing up in the console (I mean 
>>> disable JMX and set the property to DEBUG)?
>>> 
>>> Best,
>>> Marco Cosentino
>>> 
>>> -
>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>> -
>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 
> 
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 

-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: log4j 2.0 - About StatusLogger logging level and console output

2014-08-01 Thread Marco Cosentino

Hi Remko,
thanks for the reply.
I'd still like something which can be enabled through system preoperties 
and logs at very early stages, for example, where the config is read from.


Marco.

On 08/01/2014 12:04 AM, Remko Popma wrote:

All you need to do is set status="trace" in your log4j2.xml config file.

So the beginning of your config looks like this:

On 2014/08/01, at 1:13, Marco Cosentino  wrote:

Hi,
I'm trying to get log4j 2.0 debug information printed out in the console but I 
couldn't manage to get them.
In log4j 1.x you would set the system property "log4j.debug".

I thought that the mechanism was similar in log4j 2.x and apparently it should 
be by setting
log4j2.StatusLogger.level=DEBUG

Still nothing, so I dug a little bit in the code and found that the 
StatusLogger logs its messages either to the listeners (if there's at least 
one) or to a SimpleLogger (logger) which is initialized in the constructor 
(method StatusLogger#logMessage()).

I found that there was a JMX listener registered so I disabled JMX beans with
log4j2.disable.jmx=true
but still no luck: the messages don't appear in the console.

I noticed though that the constructor might be the source of the problem:

private StatusLogger() {
this.logger = new SimpleLogger("StatusLogger", Level.ERROR, false, 
true, false, false, Strings.EMPTY, null, PROPS,
System.err);
this.listenersLevel = Level.toLevel(DEFAULT_STATUS_LEVEL, 
Level.WARN).intLevel();
}

The SimpleLogger is initialized using level ERROR therefore the isEnabled 
implementation in StatusLogger returns the logging level of this.logger which 
is always ERROR even if I wanted DEBUG.

Would it make sense to use DEFAULT_STATUS_LEVEL to actually set the level into 
the SimpleLogger constructor?
Why is it so hard to get debug messages showing up in the console (I mean 
disable JMX and set the property to DEBUG)?

Best,
Marco Cosentino

-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org




-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org