You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Lennart Goedhart <le...@omnibase.com.au> on 2004/05/19 01:52:52 UTC

ODBCAppender on Linux

I'm using log4cxx on both Windows and Linux.
Here's my conf file:
------------------------------------------------
log4j.rootLogger=INFO, logFile, database

# Local log file settings for the application
log4j.appender.logFile=org.apache.log4j.RollingFileAppender
log4j.appender.logFile.File=server.log
log4j.appender.logFile.MaxFileSize=100KB
# Keep one backup file
log4j.appender.logFile.MaxBackupIndex=1
log4j.appender.logFile.layout=org.apache.log4j.PatternLayout
log4j.appender.logFile.layout.ConversionPattern=%5p %d [%t] - %m%n

# Database appender (using PostgreSQL ODBC)
log4j.appender.database=org.apache.log4j.ODBCAppender
log4j.appender.database.URL=postgresql
log4j.appender.database.layout=org.apache.log4j.PatternLayout
log4j.appender.database.layout.ConversionPattern=%5p %d %m%n
log4j.appender.database.sql=INSERT INTO events ( level, date, message )
VALUES ('%5p', '%d', '%m%n' )
------------------------------------------------

This works perfectly under Windows.
On Linux, I get the following output when I run my app:

Class 'org.apache.log4j.ODBCAppender' not found
Could not instantiate appender named "database"

When I configured on Linux, I ran:
# ./configure --prefix=/usr --enable-unicode -with-ODBC=unixODBC
When configure runs, it finds the unixODBC headers okay.

Am I missing something else?

Regards
Lennart


Re: ODBCAppender on Linux

Posted by Lennart Goedhart <le...@omnibase.com.au>.
Right. I've sorted out what the problem is (after writing some code to use
the ODBCAppender in code, rather than from a config file).
It seems on my system, that even though I pass -with-ODBC=unixODBC to
"configure", the "HAVE_ODBC" preprocessor definition is not included in the
"src/Makefile". It does appear correctly in include/log4cxx/config_auto.h
If I manually hack src/Makefile, adding HAVE_ODBC, and run "make" and "make
install" again, all works perfectly.

----- Original Message ----- 
From: "Lennart Goedhart" <le...@omnibase.com.au>
To: "Log4CXX User" <lo...@logging.apache.org>
Sent: Thursday, May 20, 2004 12:11 PM
Subject: Re: ODBCAppender on Linux


> I am logging against the .so as far as I know...
> To make things easy on myself, I stripped the project right down to this:
> Test.cpp:
> ------------------------------------------------------------
> #include <log4cxx/logger.h>
> #include <log4cxx/propertyconfigurator.h>
>
> using namespace log4cxx;
>
> int main(int argc, char* argv[])
> {
>     LoggerPtr logger = Logger::getLogger( "main" );
>     PropertyConfigurator::configure( "logging.cfg" );
>     logger->info( "Testing the log4cxx stuff" );
>
>     return 0;
> }
> ------------------------------------------------------------
>
> Again, using the logging.cfg file below, it ran fine on Windows, same
error
> on Linux, with Linux still writing okay to the RollingFileAppender.
> Here is the command line I used to compile it under Linux:
> # g++ -o Test Test.cpp -llog4cxx
>
> ----- Original Message ----- 
> From: "Pete Rowley" <pe...@openrowley.com>
> To: "Log4CXX User" <lo...@logging.apache.org>
> Sent: Wednesday, May 19, 2004 10:08 AM
> Subject: Re: ODBCAppender on Linux
>
>
> > I had something similar recently - turned out I goofed by linking
against
> > the .a, linking against the .la or the .so fixed the problem.
> >
> > ----- Original Message ----- 
> > From: "Lennart Goedhart" <le...@omnibase.com.au>
> > To: <lo...@logging.apache.org>
> > Sent: Tuesday, May 18, 2004 4:52 PM
> > Subject: ODBCAppender on Linux
> >
> >
> > > I'm using log4cxx on both Windows and Linux.
> > > Here's my conf file:
> > > ------------------------------------------------
> > > log4j.rootLogger=INFO, logFile, database
> > >
> > > # Local log file settings for the application
> > > log4j.appender.logFile=org.apache.log4j.RollingFileAppender
> > > log4j.appender.logFile.File=server.log
> > > log4j.appender.logFile.MaxFileSize=100KB
> > > # Keep one backup file
> > > log4j.appender.logFile.MaxBackupIndex=1
> > > log4j.appender.logFile.layout=org.apache.log4j.PatternLayout
> > > log4j.appender.logFile.layout.ConversionPattern=%5p %d [%t] - %m%n
> > >
> > > # Database appender (using PostgreSQL ODBC)
> > > log4j.appender.database=org.apache.log4j.ODBCAppender
> > > log4j.appender.database.URL=postgresql
> > > log4j.appender.database.layout=org.apache.log4j.PatternLayout
> > > log4j.appender.database.layout.ConversionPattern=%5p %d %m%n
> > > log4j.appender.database.sql=INSERT INTO events ( level, date,
message )
> > > VALUES ('%5p', '%d', '%m%n' )
> > > ------------------------------------------------
> > >
> > > This works perfectly under Windows.
> > > On Linux, I get the following output when I run my app:
> > >
> > > Class 'org.apache.log4j.ODBCAppender' not found
> > > Could not instantiate appender named "database"
> > >
> > > When I configured on Linux, I ran:
> > > # ./configure --prefix=/usr --enable-unicode -with-ODBC=unixODBC
> > > When configure runs, it finds the unixODBC headers okay.
> > >
> > > Am I missing something else?
> > >
> > > Regards
> > > Lennart
> > >
> > >
> >
>


Re: ODBCAppender on Linux

Posted by Lennart Goedhart <le...@omnibase.com.au>.
I am logging against the .so as far as I know...
To make things easy on myself, I stripped the project right down to this:
Test.cpp:
------------------------------------------------------------
#include <log4cxx/logger.h>
#include <log4cxx/propertyconfigurator.h>

using namespace log4cxx;

int main(int argc, char* argv[])
{
    LoggerPtr logger = Logger::getLogger( "main" );
    PropertyConfigurator::configure( "logging.cfg" );
    logger->info( "Testing the log4cxx stuff" );

    return 0;
}
------------------------------------------------------------

Again, using the logging.cfg file below, it ran fine on Windows, same error
on Linux, with Linux still writing okay to the RollingFileAppender.
Here is the command line I used to compile it under Linux:
# g++ -o Test Test.cpp -llog4cxx

----- Original Message ----- 
From: "Pete Rowley" <pe...@openrowley.com>
To: "Log4CXX User" <lo...@logging.apache.org>
Sent: Wednesday, May 19, 2004 10:08 AM
Subject: Re: ODBCAppender on Linux


> I had something similar recently - turned out I goofed by linking against
> the .a, linking against the .la or the .so fixed the problem.
>
> ----- Original Message ----- 
> From: "Lennart Goedhart" <le...@omnibase.com.au>
> To: <lo...@logging.apache.org>
> Sent: Tuesday, May 18, 2004 4:52 PM
> Subject: ODBCAppender on Linux
>
>
> > I'm using log4cxx on both Windows and Linux.
> > Here's my conf file:
> > ------------------------------------------------
> > log4j.rootLogger=INFO, logFile, database
> >
> > # Local log file settings for the application
> > log4j.appender.logFile=org.apache.log4j.RollingFileAppender
> > log4j.appender.logFile.File=server.log
> > log4j.appender.logFile.MaxFileSize=100KB
> > # Keep one backup file
> > log4j.appender.logFile.MaxBackupIndex=1
> > log4j.appender.logFile.layout=org.apache.log4j.PatternLayout
> > log4j.appender.logFile.layout.ConversionPattern=%5p %d [%t] - %m%n
> >
> > # Database appender (using PostgreSQL ODBC)
> > log4j.appender.database=org.apache.log4j.ODBCAppender
> > log4j.appender.database.URL=postgresql
> > log4j.appender.database.layout=org.apache.log4j.PatternLayout
> > log4j.appender.database.layout.ConversionPattern=%5p %d %m%n
> > log4j.appender.database.sql=INSERT INTO events ( level, date, message )
> > VALUES ('%5p', '%d', '%m%n' )
> > ------------------------------------------------
> >
> > This works perfectly under Windows.
> > On Linux, I get the following output when I run my app:
> >
> > Class 'org.apache.log4j.ODBCAppender' not found
> > Could not instantiate appender named "database"
> >
> > When I configured on Linux, I ran:
> > # ./configure --prefix=/usr --enable-unicode -with-ODBC=unixODBC
> > When configure runs, it finds the unixODBC headers okay.
> >
> > Am I missing something else?
> >
> > Regards
> > Lennart
> >
> >
>


Re: ODBCAppender on Linux

Posted by Pete Rowley <pe...@openrowley.com>.
I had something similar recently - turned out I goofed by linking against
the .a, linking against the .la or the .so fixed the problem.

----- Original Message ----- 
From: "Lennart Goedhart" <le...@omnibase.com.au>
To: <lo...@logging.apache.org>
Sent: Tuesday, May 18, 2004 4:52 PM
Subject: ODBCAppender on Linux


> I'm using log4cxx on both Windows and Linux.
> Here's my conf file:
> ------------------------------------------------
> log4j.rootLogger=INFO, logFile, database
>
> # Local log file settings for the application
> log4j.appender.logFile=org.apache.log4j.RollingFileAppender
> log4j.appender.logFile.File=server.log
> log4j.appender.logFile.MaxFileSize=100KB
> # Keep one backup file
> log4j.appender.logFile.MaxBackupIndex=1
> log4j.appender.logFile.layout=org.apache.log4j.PatternLayout
> log4j.appender.logFile.layout.ConversionPattern=%5p %d [%t] - %m%n
>
> # Database appender (using PostgreSQL ODBC)
> log4j.appender.database=org.apache.log4j.ODBCAppender
> log4j.appender.database.URL=postgresql
> log4j.appender.database.layout=org.apache.log4j.PatternLayout
> log4j.appender.database.layout.ConversionPattern=%5p %d %m%n
> log4j.appender.database.sql=INSERT INTO events ( level, date, message )
> VALUES ('%5p', '%d', '%m%n' )
> ------------------------------------------------
>
> This works perfectly under Windows.
> On Linux, I get the following output when I run my app:
>
> Class 'org.apache.log4j.ODBCAppender' not found
> Could not instantiate appender named "database"
>
> When I configured on Linux, I ran:
> # ./configure --prefix=/usr --enable-unicode -with-ODBC=unixODBC
> When configure runs, it finds the unixODBC headers okay.
>
> Am I missing something else?
>
> Regards
> Lennart
>
>