Paul Butcher | 3 Jun 2005 14:14
Gravatar

Status of stream.h?

I am having problems with the code within <log4cxx/stream.h>. Using it in a 
single source file works fine, but when I try to use it more than once, I get 
the following when linking:

In function `operator<<(log4cxx::logstream&, char const*)':
log4cxx/stream.h:153: multiple definition of `operator<<(log4cxx::logstream&, 
char const*)'

Plus a lot of other similar errors.

I'm using g++ (GCC) 3.3.4 (pre 3.3.5 20040809).

I get the impression that this code is still evolving? Is it ready for "prime 
time" yet? 

A wider question: what is the preferred mechanism for generating log messages 
which are more than just fixed strings?

Thanks in advance!

paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

maryline royer | 3 Jun 2005 17:32
Picon

Localization

Hello,

I used to do localization with log4cxx-0.9.7.

I have reintroduced this feature in the cvs version of mai 2005. I have 
tested my work. I send you the modified files :  just look if you are 
interested by my proposal ...

Best regards.
/*
 * Copyright 2003-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <log4cxx/logger.h>
#include <log4cxx/spi/loggingevent.h>
#include <log4cxx/logmanager.h>
(Continue reading)

Andreas Fester | 3 Jun 2005 21:18
Picon
Picon

Re: Status of stream.h?

Hi Paul,

Paul Butcher wrote:
> I am having problems with the code within <log4cxx/stream.h>. Using it in a 
> single source file works fine, but when I try to use it more than once, I get 
> the following when linking:
> 
> In function `operator<<(log4cxx::logstream&, char const*)':
> log4cxx/stream.h:153: multiple definition of `operator<<(log4cxx::logstream&, 
> char const*)'

I can reproduce this. I created some cpp files with content similar to

#include <log4cxx/level.h>
#include <log4cxx/logger.h>
#include <log4cxx/stream.h>

#include "src1.h"

using namespace log4cxx;

static LoggerPtr logger = Logger::getLogger(L"Src1");

void src1() {
   logstream info(logger, Level::INFO);
   info << "In src1.cpp" << 4.5 << " / " << 4;

   info.flush();
}

(Continue reading)

Labour, Matthieu (MLPRO SF | 3 Jun 2005 23:08
Picon
Favicon

Error when running ./autogen.sh on Linux when building log4cxx-0.9.7

Hi I am getting the following error when running ./autogen.sh on linux Red Hat Enterprise Linux AS release 3 (Taroon Update 4)

I see that some people had the same error but  I don't really understand how to solve it. Thank you for your help

I am using:
GNU m4 1.4.1
Aclocal 1.9.5
Autoversion 2.59
autoconf 2.59
Automake 1.9.5

bash-2.05b$ ./autogen.sh
aclocal:configure.in:32: warning: macro `AM_PROG_LIBTOOL' not found in library
Use of uninitialized value in concatenation (.) or string at /tools/gnu/autoconf-2.59/share/autoconf/Autom4te/XFile.pm line 229.

Use of uninitialized value in concatenation (.) or string at /tools/gnu/autoconf-2.59/share/autoconf/Autom4te/XFile.pm line 229.

Use of uninitialized value in concatenation (.) or string at /tools/gnu/autoconf-2.59/share/autoconf/Autom4te/XFile.pm line 229.

configure.in:32: error: possibly undefined macro: AM_PROG_LIBTOOL
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
Use of uninitialized value in concatenation (.) or string at /tools/gnu/autoconf-2.59/share/autoconf/Autom4te/XFile.pm line 229.

configure.in: installing `./install-sh'
configure.in: installing `./missing'
examples/Makefile.am: installing `./depcomp'
src/Makefile.am:1: Libtool library used but `LIBTOOL' is undefined
src/Makefile.am:1:
src/Makefile.am:1: The usual way to define `LIBTOOL' is to add `AC_PROG_LIBTOOL'
src/Makefile.am:1: to `configure.in' and run `aclocal' and `autoconf' again.

If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail.     http://www.ml.com/email_terms/
Andreas Fester | 4 Jun 2005 09:56
Picon
Picon

Re: Error when running ./autogen.sh on Linux when building log4cxx-0.9.7

Matthieu,

> Hi I am getting the following error when running ./autogen.sh on linux 
> Red Hat Enterprise Linux AS release 3 (Taroon Update 4)
> 
> I see that some people had the same error but  I don't really understand 
> how to solve it. Thank you for your help

Do you have libtool installed?
Anyway, I would like to propose that you use the package from
http://littletux.homelinux.org/debian/log4cxx/log4cxx_0.9.7.orig.tar.gz
which is identical to the apache log4cxx_0.9.7.tar.gz but already has
the configure script, so that you do not need to run autogen.sh
anymore. Simply use

./configure ; make

as usual.

Best Regards,

	Andreas

--

-- 
Andreas Fester
mailto:Andreas.Fester <at> gmx.de
WWW: http://littletux.homelinux.org
ICQ: 326674288

Andreas Fester | 4 Jun 2005 10:59
Picon
Picon

Re: Status of stream.h?

Hi,

there were some global operator definitions in the header file which
caused the multiple definition errors. Apply the attached patch
to fix the problem.

Curt: I would like to suggest to rename "stream.h" to "logstream.h"
because this is also the name of the class and it gives a better
idea of what the header file is for.

Best Regards,

	Andreas

Paul Butcher wrote:
> I am having problems with the code within <log4cxx/stream.h>. Using it in a 
> single source file works fine, but when I try to use it more than once, I get 
> the following when linking:
> 
> In function `operator<<(log4cxx::logstream&, char const*)':
> log4cxx/stream.h:153: multiple definition of `operator<<(log4cxx::logstream&, 
> char const*)'
[...]

-- 
Andreas Fester
mailto:Andreas.Fester <at> gmx.de
WWW: http://littletux.homelinux.org
ICQ: 326674288
Index: include/log4cxx/stream.h
===================================================================
RCS file: /home/cvspublic/logging-log4cxx/include/log4cxx/stream.h,v
retrieving revision 1.11
diff -u -r1.11 stream.h
--- include/log4cxx/stream.h	11 Mar 2005 06:34:48 -0000	1.11
+++ include/log4cxx/stream.h	4 Jun 2005 08:49:20 -0000
 <at>  <at>  -147,58 +147,35  <at>  <at> 

 }  // namespace log4cxx

+
 #if LOG4CXX_HAS_WCHAR_T
 log4cxx::logstream& operator<<(
   ::log4cxx::logstream& lhs,
-  const char* rhs) {
-  LOG4CXX_DECODE_CHAR(tmp, rhs);
-  LOG4CXX_ENCODE_WCHAR(msg, tmp);
-  lhs.getStream() << msg;
-  return lhs;
-}
+  const char* rhs);
 #else
 log4cxx::logstream& operator<<(
   ::log4cxx::logstream& lhs,
-  const char* rhs) {
-  LOG4CXX_DECODE_CHAR(tmp, rhs);
-  LOG4CXX_ENCODE_CHAR(msg, tmp);
-  lhs.getStream() << msg;
-  return lhs;
-}
+  const char* rhs);
 #endif

-
 ::log4cxx::logstream& operator<<(
    ::log4cxx::logstream& lhs,
-   const ::log4cxx::spi::LocationInfo& rhs) {
-   lhs.setLocation(rhs);
-   return lhs;
-}
+   const ::log4cxx::spi::LocationInfo& rhs);

 
 ::log4cxx::logstream& operator<<(
    ::log4cxx::logstream& lhs,
-   const ::log4cxx::spi::LocationFlush& rhs) {
-   lhs.flush(rhs);
-   return lhs;
-}
+   const ::log4cxx::spi::LocationFlush& rhs);
+

 ::log4cxx::logstream& operator<<(
    ::log4cxx::logstream& lhs,
-   const ::log4cxx::LevelPtr& rhs) {
-   lhs.setLevel(rhs);
-   return lhs;
-}
+   const ::log4cxx::LevelPtr& rhs);

 
 ::log4cxx::logstream& operator<<(
    ::log4cxx::logstream& lhs,
-   ::std::ios_base& (*manip)(::std::ios_base&)) {
-     (*manip)(lhs);
-   return lhs;
-}
-
-
+   ::std::ios_base& (*manip)(::std::ios_base&));

 
 //
 <at>  <at>  -214,6 +191,7  <at>  <at> 
    return lhs;
 }

+
 #if !defined(LOG4CXX_ENDMSG)
 #define LOG4CXX_ENDMSG LOG4CXX_LOCATION_FLUSH
 #endif
Index: src/Makefile.am
===================================================================
RCS file: /home/cvspublic/logging-log4cxx/src/Makefile.am,v
retrieving revision 1.30
diff -u -r1.30 Makefile.am
--- src/Makefile.am	1 Jun 2005 18:40:26 -0000	1.30
+++ src/Makefile.am	4 Jun 2005 08:49:21 -0000
 <at>  <at>  -67,6 +67,7  <at>  <at> 
         loggingevent.cpp \
         loglog.cpp \
         logmanager.cpp \
+        logstream.cpp \
         manualtriggeringpolicy.cpp \
         messagepatternconverter.cpp \
         methodlocationpatternconverter.cpp \
Index: src/logstream.cpp
===================================================================
RCS file: src/logstream.cpp
diff -N src/logstream.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/logstream.cpp	4 Jun 2005 08:49:21 -0000
 <at>  <at>  -0,0 +1,67  <at>  <at> 
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <log4cxx/stream.h>
+
+#if LOG4CXX_HAS_WCHAR_T
+log4cxx::logstream& operator<<(
+  ::log4cxx::logstream& lhs,
+  const char* rhs) {
+  LOG4CXX_DECODE_CHAR(tmp, rhs);
+  LOG4CXX_ENCODE_WCHAR(msg, tmp);
+  lhs.getStream() << msg;
+  return lhs;
+}
+#else
+log4cxx::logstream& operator<<(
+  ::log4cxx::logstream& lhs,
+  const char* rhs) {
+  LOG4CXX_DECODE_CHAR(tmp, rhs);
+  LOG4CXX_ENCODE_CHAR(msg, tmp);
+  lhs.getStream() << msg;
+  return lhs;
+}
+#endif
+
+::log4cxx::logstream& operator<<(
+   ::log4cxx::logstream& lhs,
+   const ::log4cxx::spi::LocationInfo& rhs) {
+   lhs.setLocation(rhs);
+   return lhs;
+}
+
+
+::log4cxx::logstream& operator<<(
+   ::log4cxx::logstream& lhs,
+   const ::log4cxx::spi::LocationFlush& rhs) {
+   lhs.flush(rhs);
+   return lhs;
+}
+
+::log4cxx::logstream& operator<<(
+   ::log4cxx::logstream& lhs,
+   const ::log4cxx::LevelPtr& rhs) {
+   lhs.setLevel(rhs);
+   return lhs;
+}
+
+
+::log4cxx::logstream& operator<<(
+   ::log4cxx::logstream& lhs,
+   ::std::ios_base& (*manip)(::std::ios_base&)) {
+     (*manip)(lhs);
+   return lhs;
+}
Raoul OPPLIGER | 4 Jun 2005 16:44
Picon

A error message with JdbcAppender

I use log4j with a xml configuration file.
 
I don't have problems when I use FileAppender but when I introduce a jdbcAppender in my config file
 
<appender name="system_system_3_database" class="org.apache.log4j.jdbc.JDBCAppender">
   <param name="URL" value="jdbc:mysql://localhost/OSP"/>
   <param name="driver" value="com.mysql.jdbc.Driver"/>
   <param name="user" value="root"/>
   <param name="password" value=""/>
   <param name="sql" value="insert into ........."/>
   <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d - %c -%-4r [%t] %-5p %c %x - %m%n "/>
   </layout>
</appender>
I've the following message with DOMConfigurator (mysql-connector-java-3.0.16-ga-bin.jar is in my project CLASSPATH)
 
log4j:ERROR Failed to load driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
 at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:141)
 at org.apache.log4j.jdbc.JDBCAppender.setDriver(JDBCAppender.java:336)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:324)
 at org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:196)
 at org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:155)
 at org.apache.log4j.xml.DOMConfigurator.setParameter(DOMConfigurator.java:530)
 at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:182)
 at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140)
 at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153)
 at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415)
 at org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:335)
 at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:781)
 at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666)
 at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
 at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:584)
 at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:687)
 at ch.consultas.osp.webcrawling.Log.initialize(Log.java:72)
 at mypackage1.Hello.main(Hello.java:20)
log4j:ERROR Failed to load driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
 at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:141)
 at org.apache.log4j.jdbc.JDBCAppender.setDriver(JDBCAppender.java:336)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:324)
 at org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:196)
 at org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:155)
 at org.apache.log4j.xml.DOMConfigurator.setParameter(DOMConfigurator.java:530)
 at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:182)
 at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140)
 at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153)
 at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415)
 at org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:335)
 at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:781)
 at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666)
 at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
 at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:584)
 at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:687)
 at ch.consultas.osp.webcrawling.Log.initialize(Log.java:72)
 at mypackage1.Hello.main(Hello.java:20)
Debugger disconnected from local process.
Process exited.
 
Can you help me?
 
Raoul
Andreas Fester | 4 Jun 2005 19:04
Picon
Picon

Re: A error message with JdbcAppender

Hi Raoul,

seems that you hit the wrong mailing list :-) - log4cxx is for
the C++ port of log4j. To not loose context, I appended your full
original mail and forwarded it to log4j-user <at> logging.apache.org.

Although you said that mysql-connector-java-3.0.16-ga-bin.jar is
in your classpath those kind of problems are almost always
a misconfigured classpath. Please try the attached test program
with the also attached .xml configuration file -
When I start it (on Unix) with

   java -cp lib/log4j-1.2.9.jar:. LogTest

I get exactly your error, but when I start it with

   java -cp lib/mysql-connector-java-3.1.8-bin.jar:lib/log4j-1.2.9.jar:. 
LogTest

I get a connection error (because I have no mysql database running),
but at least the driver was loaded.

Your mysql-connector 3.0.16 seems a bit out of date, I downloaded a
current one from the mysql homepage. I use log4j 1.2.9 with j2sdk 1.4.2.

HTH,

	Andreas

Raoul OPPLIGER wrote:
> I use log4j with a xml configuration file.
>  
> I don't have problems when I use FileAppender but when I introduce a 
> jdbcAppender in my config file
>  
> <appender name="system_system_3_database" 
> class="org.apache.log4j.jdbc.JDBCAppender">
>    <param name="URL" value="jdbc:mysql://localhost/OSP"/>
>    <param name="driver" value="com.mysql.jdbc.Driver"/>
>    <param name="user" value="root"/>
>    <param name="password" value=""/>
>    <param name="sql" value="insert into ........."/>
>    <layout class="org.apache.log4j.PatternLayout">
>       <param name="ConversionPattern" value="%d - %c -%-4r [%t] %-5p %c 
> %x - %m%n "/>
>    </layout>
> </appender>
> I've the following message with DOMConfigurator 
> (mysql-connector-java-3.0.16-ga-bin.jar is in my project CLASSPATH)
>  
> log4j:ERROR Failed to load driver
> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
>  at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
>  at java.security.AccessController.doPrivileged(Native Method)
>  at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
>  at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
>  at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
>  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
>  at java.lang.Class.forName0(Native Method)
>  at java.lang.Class.forName(Class.java:141)
>  at org.apache.log4j.jdbc.JDBCAppender.setDriver(JDBCAppender.java:336)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>  at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>  at java.lang.reflect.Method.invoke(Method.java:324)
>  at 
> org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:196)
>  at 
> org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:155)
>  at 
> org.apache.log4j.xml.DOMConfigurator.setParameter(DOMConfigurator.java:530)
>  at 
> org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:182)
>  at 
> org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140)
>  at 
> org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153)
>  at 
> org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415)
>  at 
> org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:335)
>  at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:781)
>  at 
> org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666)
>  at 
> org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
>  at 
> org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:584)
>  at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:687)
>  at ch.consultas.osp.webcrawling.Log.initialize(Log.java:72)
>  at mypackage1.Hello.main(Hello.java:20)
> log4j:ERROR Failed to load driver
> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
>  at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
>  at java.security.AccessController.doPrivileged(Native Method)
>  at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
>  at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
>  at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
>  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
>  at java.lang.Class.forName0(Native Method)
>  at java.lang.Class.forName(Class.java:141)
>  at org.apache.log4j.jdbc.JDBCAppender.setDriver(JDBCAppender.java:336)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>  at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>  at java.lang.reflect.Method.invoke(Method.java:324)
>  at 
> org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:196)
>  at 
> org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:155)
>  at 
> org.apache.log4j.xml.DOMConfigurator.setParameter(DOMConfigurator.java:530)
>  at 
> org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:182)
>  at 
> org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140)
>  at 
> org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153)
>  at 
> org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415)
>  at 
> org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:335)
>  at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:781)
>  at 
> org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666)
>  at 
> org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
>  at 
> org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:584)
>  at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:687)
>  at ch.consultas.osp.webcrawling.Log.initialize(Log.java:72)
>  at mypackage1.Hello.main(Hello.java:20)
> Debugger disconnected from local process.
> Process exited.
>  
> Can you help me?
>  
> Raoul

--

-- 
Andreas Fester
mailto:Andreas.Fester <at> gmx.de
WWW: http://littletux.homelinux.org
ICQ: 326674288
Attachment (LogTest.java): text/x-java, 242 bytes
Attachment (log4j.xml): text/xml, 1198 bytes
Curt Arnold | 6 Jun 2005 20:57
Picon
Favicon

Re: Status of stream.h?


On Jun 3, 2005, at 7:14 AM, Paul Butcher wrote:

> I am having problems with the code within <log4cxx/stream.h>. Using  
> it in a
> single source file works fine, but when I try to use it more than  
> once, I get
> the following when linking:
>
> In function `operator<<(log4cxx::logstream&, char const*)':
> log4cxx/stream.h:153: multiple definition of `operator<< 
> (log4cxx::logstream&,
> char const*)'
>
> Plus a lot of other similar errors.
>
> I'm using g++ (GCC) 3.3.4 (pre 3.3.5 20040809).
>
> I get the impression that this code is still evolving? Is it ready  
> for "prime
> time" yet?
>

It has been stalled for quite some time, however Christopher Smith  
has expressed interest in restarting it.  The semantics shouldn't  
change much but the current approach has a surprisingly high cost to  
instantiate a logstream object.  It is not trivial to preserve the  
STL stream semantics while deferring the startup cost until the first  
logging request that satisfies the criteria.

> A wider question: what is the preferred mechanism for generating  
> log messages
> which are more than just fixed strings?

log4j's CVS HEAD has a parameterized log methods that could mimicked  
in log4cxx, but I haven't mocked anything out.  The new log4j methods  
are something like:

logger.info("Hello, {}.", "World");

It isn't the most general approach, but it does cover a huge amount  
of common use cases.

>
> Thanks in advance!
>
> paul.butcher->msgCount++
>
> Snetterton, Castle Combe, Cadwell Park...
> Who says I have a one track mind?
>

Paul Butcher | 6 Jun 2005 23:00
Gravatar

Re: Status of stream.h?

Thanks for the various responses on this topic.

On Monday 06 June 2005 19:57, Curt Arnold wrote:
> It has been stalled for quite some time, however Christopher Smith
> has expressed interest in restarting it.  The semantics shouldn't
> change much but ...

I haven't looked into it in great detail, so can't suggest a solution, but I 
suspect that it will need a change to the semantics to be useful. At the 
moment, very simple constructs like:

  log4cxx::logstream ls(logger, Level::DEBUG);
  std::string s = "Test";
  ls << s;

fail (with a very long template-related error message which I won't reproduce 
here).

It seems to work with simple types (char*, int, etc) but not with anything 
more complex :-(

> log4j's CVS HEAD has a parameterized log methods that could mimicked
> in log4cxx, but I haven't mocked anything out.  The new log4j methods
> are something like:
>
> logger.info("Hello, {}.", "World");
>
> It isn't the most general approach, but it does cover a huge amount
> of common use cases.

Thanks - but am I right in thinking that this isn't available in log4cxx just 
yet?

What I've been doing for the time being is this kind of thing:

  std::ostringstream message;
  message << ... ;
  LOG4CXX_DEBUG(logger, message.str());

or, if efficiency matters:

  if(logger->isDebugEnabled())
  {
    std::ostringstream message;
    message << ... ;
    LOG4CXX_DEBUG(logger, message.str());
  }

Is this the best option with the package as it currently stands? Or is there a 
better alternative?

Thanks!

paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?


Gmane