You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Guerra, Francesco" <Fr...@qwest.com> on 2007/05/08 21:45:14 UTC

DBAppender configuration in log4j.properties

I have a working example of the log4j.xml file to configure the
DBAppender. But I can not create the equivalent in a name/value pair
format of a log4j.properties.

This is what I tried: log4j.appender.DB=org.apache.log4j.db.DBAppender
log4j.appender.DB.layout=org.apache.log4j.PatternLayout
log4j.appender.DB.layout.ConversionPattern=%d %-5p [%t] %c - %m%n
log4j.appender.DB.connectionSource=org.apache.log4j.db.DriverManagerConn
ectionSource
log4j.appender.DB.connectionSource.driverClass=com.mysql.jdbc.Driver
log4j.appender.DB.connectionSource.url=jdbc:mysql://lxdnd729.dev.qintra.
com:3306/ACCESS_MANAGER_LOG
log4j.appender.DB.connectionSource.user=yyyy
log4j.appender.DB.connectionSource.password=xxx

I am getting the following error:
 WARN [main] (PropertySetter.java:178) - Failed to set property
[connectionSource] to value
"org.apache.log4j.db.DriverManagerConnectionSource". 
org.apache.log4j.config.PropertySetterException: Conversion to type
[interface org.apache.log4j.db.ConnectionSource] failed.

Could anybody help me with this?

Thank you,
Francesco


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.

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


Re: DBAppender configuration in log4j.properties

Posted by Curt Arnold <ca...@apache.org>.
On May 9, 2007, at 12:45 PM, Guerra, Francesco wrote:

> I could not find the directory tests/input/db in the
> logging-log4j-1.3alpha-8.zip (full package, includes binaries and  
> source
> files): the tests directory is empty. Is there another place where  
> I can
> find examples scripts of JoranConfigurator?
>

The tests are not bundled with the source distribution.  The sample  
DB configuration files can be checked out of the SVN using:

svn co https://svn.apache.org/repos/asf/logging/log4j/trunk/tests/ 
input/db

or browsed directly by opening that URL in a browser.


> Please, note that I need to use the DBAppender for a vendor product  
> and
> I can not do any source code modification.
>
> I want to be able to change the log4j configuration used by this  
> product
> to include the DBAppender. Is this possible?
>

If your application is initialized by default initialization (that is  
not by an explicit call to PropertyConfigure.configure,  
DOMConfigurator.configure or JoranConfigurator.configure), then you  
can replace the existing log4j.properties file with a log4j.xml  
file.  Appenders that require nested objects other than layouts can  
not be configured using the PropertyConfigurator.  The pattern used  
for layout configuration is a not generalized for other types of  
nested objects.  It would have been nice if PropertyConfigurator  
would have known to interpret your string as a class name, construct  
the object and then call set methods on the constructed object, but  
all PropertyConfigurator saw was an attempt to call a method that  
required a ConnectionSource with a String.

If you app explicitly calls PropertyConfigurator, then you could  
possibly create an appender that extends DBAppender but eliminates  
the need for configuration of a nested object.  That is, you could  
create a com.example.fooapp.DBAppender that sets calls  
setConnectionSource() in either the constructor or during  
activateOptions() where all necessary configuration is expressed as  
properties on com.example.fooapp.DBAppender.


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


RE: DBAppender configuration in log4j.properties

Posted by "Guerra, Francesco" <Fr...@qwest.com>.
I could not find the directory tests/input/db in the
logging-log4j-1.3alpha-8.zip (full package, includes binaries and source
files): the tests directory is empty. Is there another place where I can
find examples scripts of JoranConfigurator?

Please, note that I need to use the DBAppender for a vendor product and
I can not do any source code modification. 

I want to be able to change the log4j configuration used by this product
to include the DBAppender. Is this possible?

I have been searching on this for quite some time. I would really
appreciate any help.

Thank you,
Francesco

-----Original Message-----
From: Kamal Ahmed [mailto:KAhmed@webMethods.com] 
Sent: Wednesday, May 09, 2007 3:45 AM
To: Log4J Users List
Subject: RE: DBAppender configuration in log4j.properties


General purpose Object property setter. Clients repeatedly invokes
setProperty(name,value) in order to invoke setters on the Object
specified in the constructor. This class relies on the JavaBeans
Introspector to analyze the given Object Class using reflection.

Usage:

PropertySetter ps = new PropertySetter(anObject); ps.set("name", "Joe");
ps.set("age", "32"); ps.set("isMale", "true");

will cause the invocations anObject.setName("Joe"), anObject.setAge(32),
and setMale(true) if such methods exist with those signatures. Otherwise
an IntrospectionException are thrown.



Configuration  DBAppender can be configured programmatically, or using
JoranConfigurator. Example scripts can be found in the tests/input/db
directory.


Here are some more hints on how to setup DBAppender

Hope this helps

-Kamal.

-----Original Message-----
From: Guerra, Francesco [mailto:Francesco.Guerra@qwest.com] 
Sent: Tuesday, May 08, 2007 3:45 PM
To: log4j-user@logging.apache.org
Subject: DBAppender configuration in log4j.properties

I have a working example of the log4j.xml file to configure the
DBAppender. But I can not create the equivalent in a name/value pair
format of a log4j.properties.

This is what I tried: log4j.appender.DB=org.apache.log4j.db.DBAppender
log4j.appender.DB.layout=org.apache.log4j.PatternLayout
log4j.appender.DB.layout.ConversionPattern=%d %-5p [%t] %c - %m%n
log4j.appender.DB.connectionSource=org.apache.log4j.db.DriverManagerConn
ectionSource
log4j.appender.DB.connectionSource.driverClass=com.mysql.jdbc.Driver
log4j.appender.DB.connectionSource.url=jdbc:mysql://lxdnd729.dev.qintra.
com:3306/ACCESS_MANAGER_LOG log4j.appender.DB.connectionSource.user=yyyy
log4j.appender.DB.connectionSource.password=xxx

I am getting the following error:
 WARN [main] (PropertySetter.java:178) - Failed to set property
[connectionSource] to value
"org.apache.log4j.db.DriverManagerConnectionSource". 
org.apache.log4j.config.PropertySetterException: Conversion to type
[interface org.apache.log4j.db.ConnectionSource] failed.

Could anybody help me with this?

Thank you,
Francesco


This communication is the property of Qwest and may contain confidential
or privileged information. Unauthorized use of this communication is
strictly 
prohibited and may be unlawful.  If you have received this communication

in error, please immediately notify the sender by reply e-mail and
destroy 
all copies of the communication and any attachments.

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

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


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


RE: DBAppender configuration in log4j.properties

Posted by Kamal Ahmed <KA...@webMethods.com>.
General purpose Object property setter. Clients repeatedly invokes
setProperty(name,value) in order to invoke setters on the Object
specified in the constructor. This class relies on the JavaBeans
Introspector to analyze the given Object Class using reflection.

Usage:

PropertySetter ps = new PropertySetter(anObject);
ps.set("name", "Joe");
ps.set("age", "32");
ps.set("isMale", "true");

will cause the invocations anObject.setName("Joe"), anObject.setAge(32),
and setMale(true) if such methods exist with those signatures. Otherwise
an IntrospectionException are thrown.



Configuration  DBAppender can be configured programmatically, or using
JoranConfigurator. Example scripts can be found in the tests/input/db
directory.


Here are some more hints on how to setup DBAppender

Hope this helps

-Kamal.

-----Original Message-----
From: Guerra, Francesco [mailto:Francesco.Guerra@qwest.com] 
Sent: Tuesday, May 08, 2007 3:45 PM
To: log4j-user@logging.apache.org
Subject: DBAppender configuration in log4j.properties

I have a working example of the log4j.xml file to configure the
DBAppender. But I can not create the equivalent in a name/value pair
format of a log4j.properties.

This is what I tried: log4j.appender.DB=org.apache.log4j.db.DBAppender
log4j.appender.DB.layout=org.apache.log4j.PatternLayout
log4j.appender.DB.layout.ConversionPattern=%d %-5p [%t] %c - %m%n
log4j.appender.DB.connectionSource=org.apache.log4j.db.DriverManagerConn
ectionSource
log4j.appender.DB.connectionSource.driverClass=com.mysql.jdbc.Driver
log4j.appender.DB.connectionSource.url=jdbc:mysql://lxdnd729.dev.qintra.
com:3306/ACCESS_MANAGER_LOG
log4j.appender.DB.connectionSource.user=yyyy
log4j.appender.DB.connectionSource.password=xxx

I am getting the following error:
 WARN [main] (PropertySetter.java:178) - Failed to set property
[connectionSource] to value
"org.apache.log4j.db.DriverManagerConnectionSource". 
org.apache.log4j.config.PropertySetterException: Conversion to type
[interface org.apache.log4j.db.ConnectionSource] failed.

Could anybody help me with this?

Thank you,
Francesco


This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly 
prohibited and may be unlawful.  If you have received this communication

in error, please immediately notify the sender by reply e-mail and
destroy 
all copies of the communication and any attachments.

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

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