Re: C++ using Qt and Log4cxx does not show in console

2013-05-21 Thread Jacob L. Anawalt

On 5/21/2013 11:44 AM, Mike wrote:

I am attempting to use log4cxx to write to the Visual Studio (2008) console.


Do you mean the VS debug output window via OutputDebugString, or are you talking 
about a standard console via AllocConsole or a Win32 console application?




--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


Re: Javadoc link dead on http://logging.apache.org/log4cxx/

2013-02-26 Thread Jacob L. Anawalt

On 2/26/2013 9:42 AM, Rhys Ulerich wrote:

The API Documentation link on the main log4cxx site, which points to
http://logging.apache.org/log4cxx/apidocs/index.html, is dead.



I noticed that it tries to point to log4cxx-0.11.0-SNAPSHOT and in the wiki that 
link is marked out. The version 0.10.0 link appears to work:


http://wiki.apache.org/logging-log4cxx/


https://svn.apache.org/repos/asf/logging/site/trunk/docs/log4cxx/apidocs/index.html

--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


Re: Using NDC?

2012-05-22 Thread Jacob L. Anawalt

On 2012-05-22 16:41, Christopher Nagel wrote:

1. NDC should not auto-pop() until a functional boundary is reached - in other
words, IF branches should not cause pop() but new functions should.


I appreciate the scoped (RAII) behavior of the constructor based NDC push/pop, 
as documented in the API docs under NDC Constructor  Destructor Documentation.


http://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1_n_d_c.html

If you don't want an if statement to push/pop, don't create new stack based 
instances within the if scope. Instead consider using the static push and pop 
methods. Eg:


if( some condition )
log4cxx::NDC::push(m_loggingContext);

http://wiki.apache.org/logging-log4cxx/NestedDiagnosticContexts

--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


Re: SyslogAppender not working

2011-02-16 Thread Jacob L. Anawalt

On 2/16/2011 2:09 AM, security veteran wrote:

Hi,

I'm trying to use log4cxx to log messages to a remote syslog server.
To begin with, I tried to log the message to the local syslog server
for a simple testing.



I use a SyslogAppender, but my configuration is different so I can't 
do a quick apples to apples comparison.


Verify that you can log locally and remotely using the logger command 
(assuming some kind of UNIX like environment) or similar.


http://unixhelp.ed.ac.uk/CGI/man-cgi?logger+1

Try a simple log4cxx program that configures it all programatically. 
The following works for me:


// g++ -o syslogAppender syslogAppender.cpp -llog4cxx
//
#include log4cxx/logger.h
#include log4cxx/basicconfigurator.h
#include log4cxx/patternlayout.h
#include log4cxx/net/syslogappender.h


int
main(void)
{
log4cxx::BasicConfigurator::configure();

log4cxx::LayoutPtr l(new log4cxx::PatternLayout(
%-4r %-5p %c %x - %m));
log4cxx::net::SyslogAppenderPtr a(
new log4cxx::net::SyslogAppender(l
,log4cxx::net::SyslogAppender::getFacility(DAEMON)));
a-setSyslogHost(127.0.0.1);
a-activateOptions();

log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(MyApp));
logger-addAppender(a);

while(true) {
LOG4CXX_INFO(logger,beep);
sleep(15);
}

return EXIT_SUCCESS;
}


--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


Re: get method name of logging caller...

2010-10-15 Thread Jacob L. Anawalt

On 10/15/2010 5:53 AM, Thorsten Schöning wrote:

Hello,

is there any way to get the method name of the logging caller in the
log message?


As you say, the log4j docs document %M in the PatternLayout (while 
log4cxx does not) but caution against the inefficiency of it's use. 
Additionally The Complete Log4J Manual (a good document to have) 
points out that even in Java this information can be discarded by the 
compiler.


In log4cxx %F and %L provide the file name and line number 
respectively, but that is because they can rely on the ubiquitious 
__FILE__ and __LINE__ macros. The LOG4CXX_LOCATION macro is documented 
to use __LOG4CXX_FUNC__ with a value of .


If your compiler and flags support __FUNCTION__, you could work that 
into your message or change the definition of __LOG4CXX_FUNC__ and go 
on to implement %M.


I haven't even glanced at the code to see where that's at. I just 
inflexibly typed the function name into a DEBUG message near the top 
of the message call, or sometimes used a NDC to track the call stack 
in debug logs.


Good luck,
--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


Re: exception std::out_of_range in StringHelper::startsWith

2010-10-15 Thread Jacob L. Anawalt

On 10/12/2010 10:24 AM, Thorsten Schöning wrote:

I get an out_of_range exception everytime I use a logger which name is
longer than the name of the root logger


I'm not sure what this named root logger you're referring too. In xml 
config it's just root and in property format it's log4j.rootLogger.


I have logging hierarchies where the child logger's name is longer 
than the parent's in a java like way only I sometimes use 
abbreviations of my classes and sometimes use names/levels for 
non-class things. Eg, for a postgresql accessing class:


PQ
PQ.Worker
PQ.TX
PQ.TX.Lookup

I've been building with the GCC on Debian for a few years now without 
any out_of_range errors to do with log4cxx loggers.


--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


Re: application property

2010-05-14 Thread Jacob L. Anawalt
Doesn't it inherit from the parent thread so if you set the MDC before 
spawning any new threads it has those properties?


On 2010-05-12 08:57, Dale King wrote:
I just remembered that MDC is local to each thread, so you need to do 
this in each thread. In my case my code was a business logic DLL that 
was called by a 3rd party app which created all the threads, so I 
wrapped all my exposed entry points with MDC::put and MDC::remove.






--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


Re: File name and line numbers not working

2009-06-30 Thread Jacob L. Anawalt

On 2009-06-30 01:18, tshi...@yahoo.com wrote:

0 [0x7fba18564770] INFO main null - Entering application.



What is your PatternLayout conversion pattern for logger main?


--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


Re: Is it possible to configure appenders per log level?

2009-05-18 Thread Jacob L. Anawalt

On 2009-05-18 07:21, Assaf Lavie wrote:

Thanks.I didn't know I could set the level on an appender.
What's the syntax for that in the config file? (I couldn't find it in the
docs)



The simplest document is the short introduction on the project's main page. The 
most complete is the log4j manual. Hopefully the wiki can grow to be somewhere 
in the middle. I often use the Find page and then choose TitleIndex. The page on 
Appender talks a little about thresholds and gives a property format example.


http://wiki.apache.org/logging-log4cxx/Appender

--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


Re: config file questions

2009-04-07 Thread Jacob L. Anawalt

On 2009-04-07 13:29, Cory Riddell wrote:
Are the configuration options documented somewhere? 


The log4cxx API is patterned after the log4j one and strives to be compatible 
with it. The most complete log4j specification, short of reading the code, is 
the log4j manual. I really found myself needing this documentation when I moved 
from the Property configuration to the DOM (xml) configuration.


https://www.qos.ch/shop/products/log4j/log4j-Manual.jsp


I've seen the
examples on the quick start page but I'd like more information.
Specifically, how do the java (log4j) properties map to the c++ classes?

Take this line as an example:
  log4j.appender.R.layout=org.apache.log4j.PatternLayout

How do you parse this line?


With a PropertyConfigurator of course. :) (Properties' PropertyParser isn't 
nearly as magical as the PropertySetter and OptionConverter. See 
PropertyConfigurator::parseAppendder)



I'm guessing that *log4j.appender* equals
the log4cxx::Appender class. *R* is an instance and *.layout* somehow
invokes Appender::setLayout(), passing it a default instance of
log4cxx::PatternLayout.



While I understand the desire to know how it all works and more importantly how 
to know what class you're setting properties for and what it's options are, I 
finally just started using the library without caring what kind of thing the 
appender R is in memory.


You configure appenders of arbitrary names (I prefer ones that represent the 
type of thing they are appending to like CONSOLE and SYSLOG) and attach them to 
loggers. If you're assigning log4j.appender.LOGFILE = 
org.apache.log4j.FileAppender, then you can look at the set* functions of 
FileAppenderand it's parent WriterAppender and grandparent AppenderSkeleton to 
see the options.


You can also check the source for the appender or layout and look at the 
::setOption function.



Why do some properties have an org.apache prefix and
others do not?


When you declare appenders and layouts you specify the class on the right hand 
side. The rest of the properties are for setting values.



Could this line simply be written as
  R.layout = log4j.PatternLayout
? Can I use log4cxx rather than log4j?



See OptionConverter::instantiateByClassName and the code it calls. Specifically 
Class::forName or more simply, try it.


I use the full org.apache.log4j prefixed names just so my configuration files 
stay compatible with either API. Custom (local) classes probably shouldn't be 
loaded as org.apache.log4j to avoid the confusion and potential classpath 
collisions.


--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


Re: Addning new fields to the logs.

2009-03-17 Thread Jacob L. Anawalt

On 2009-03-16 20:27, Dale King wrote:

On Sun, Mar 15, 2009 at 4:00 PM, Rodolfo Gonzalez rgonzale...@yahoo.comwrote:

we had this new requirement to add some new unsupported fields in the log.

I don't know if this is the best way to do it works for us. Any alternative
approach will be highly appreciated.



I think you want a Mapped Diagnostic Context (MDC) which lets you add
name-value pairs in thread specific storage that you can access in the log.



That was my first thought too, but I was thinking of mostly static per-thread 
data or even per-app data that I just init before creating child threads. I 
wondered though, what about dynamic data like the time data from %r and %d. Sure 
I don't need %r and %d and could do the same by hand each call in my %m data, 
but I'm glad I don't have to. Knowing what the new unsupported fields were would 
help me decide if MDC would have been acceptable.


I got a copy of Rodolfo's code to get a better idea of what he is talking about. 
 I don't have my head around all of it, but it looks clean and flexible. I 
still feel like I haven't caught the full vision yet. I am left wondering why 
w1-w3 formats have been reserved. Was it just to provide a testing facility as 
proof of concept? I also found myself wishing for a sample implementation that 
extends a the code with some dynamic runtime data not available in the 
PatternLayout and not appropriate for an MDC.


--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


Re: Configuring log4cxx client.

2008-12-08 Thread Jacob L. Anawalt

On 2008-12-08 13:38, Greg Flex wrote:

error C2665: 'log4cxx::PropertyConfigurator:configure':none of the 2
overloads could convert all the argument types
Any ideas what might be a problem?


The error sounds like you're not passing it a log4cxx::helpers::Properties or a 
log4cxx::File by reference.


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Visual C++ Assertion failed when using LOG4CXX_DECODE_CHAR macro in statically linked MFC project

2008-12-01 Thread Jacob L. Anawalt

On 2008-12-01 06:01, Peter Doornbosch wrote:

Got it now. As  the application is defining _ MBCS, LPCTSTR is actually a
pointer to a char,


Long Pointer to a Const Tchar STRing.


which i must convert to unicode (using
MultiByteToWideChar), as the LogString constructor is expecting unicode, is
that right?



I don't know if that is the cause of your error, it would cause size differences 
when using functions that assume sizeof(character) (eg TCHAR) == sizeof(char) 
(byte) and confuse character counts with byte sizes. Seems strange that it would 
work or not depending on your use of MFC (static or not). That sounds more like 
a new/free or other memory tracking mixup.


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Hi, unable to use Log4Cxx

2008-11-24 Thread Jacob L. Anawalt

On 2008-11-21 23:49, Sylvester wrote:

Hi,
This is the first time I am using Log4Cxx. I am using MingW and eclipse 
ganymede, and for the life of me haven't figured out how to use it. I 
have added the .h files to the project they show up in the includes. 
Then I pasted the following from here 
http://wiki.apache.org/logging-log4cxx/FrequentlyAskedQuestions:


#include log4cxx/logger.h


Is this file in your source file's directory or include path? If not, are you 
using an option to specify the path to the log4cxx include folder?


Is it a compile error, or a linking error? If it is a linking error, do you have 
the log4cxx library option selected (In eclipse project properties, C/C++ Build, 
Tool Settings, C++ linker)



I'm building on a very different setup. Debian, g++ from GCC 4.1, etc. The only 
similarity is eclipse. My copy of the log4cxx headers is in my system default 
path of /usr/include/log4cxx so I include with the angle brackets, #include 
log4cxx/logger.h and it works without specifying an additional library 
location. I make sure I'm using -llog4cxx so the linker knows where to find the 
log4cxx objects.


I suggest trying to compile from the command line just to make sure it isn't 
some setting lost in translation to Eclipse.


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Log4cpp's SyslogAppender problem

2008-10-01 Thread Jacob L. Anawalt

On 2008-10-01 12:00, Hoang, Minh-Long (Mission Systems) wrote:
I'm having problem with log4cpp's SyslogAppender.  


SyslogAppender works for me (tm) but I haven't tried 0.10.x

Steps for troubleshooting:

1) Use some other app to make sure your logging setup is correct. I suggest the 
simple command line logger from the bsdutil / util-linux project:


http://freshmeat.net/projects/util-linux/

2) Use some facility that is working and being used by other apps on the system 
before trying some custom LOCAL_X facility. Combining steps 1 and 2 you should 
be very confident that you are watching the right file before moving on to step 3.


3) Write a simple log4cxx test app and try it. The attached one requires no 
external config and works fine on my systems with log4cxx 0.9.7.


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026
// 2008-0ct-01T20:30
// log4cxx example of working with an external process that rotates
// log files and sends SIGHUP to the logging app to tell it to close
// and reopen files.
//
// g++ -o syslogAppender syslogAppender.cpp -llog4cxx
//
#include log4cxx/logger.h
#include log4cxx/basicconfigurator.h
#include log4cxx/patternlayout.h
#include log4cxx/net/syslogappender.h


int 
main(void)
{
log4cxx::BasicConfigurator::configure();

log4cxx::LayoutPtr l(new log4cxx::PatternLayout(
%-4r %-5p %c %x - %m));
log4cxx::net::SyslogAppenderPtr a(
new log4cxx::net::SyslogAppender(l
,log4cxx::net::SyslogAppender::getFacility(DAEMON)));
a-setSyslogHost(127.0.0.1);
a-activateOptions();

log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(MyApp));
logger-addAppender(a);

while(true) {
LOG4CXX_INFO(logger,beep);
sleep(15);
}

return EXIT_SUCCESS;
}


Re: File system full causes log4cxx to crash

2008-09-22 Thread Jacob L. Anawalt

On 2008-09-20 11:37, Peter Steele wrote:

We've experienced several cases of our logging volume becoming full
during the course of execution of our application. What we would like to
happen in this case is simply to lose any log further messages that are
written after the file system becomes full


I wanted to know what would happen to my programs using log4cxx (0.9.7) in this 
case so I wrote a couple of test apps and created a 1MiB block file and mounted 
it as a loop device in /mnt.


First I tried a simple C app using open and blocking write to see what happens. 
By picking a buffer size of 8096 I was able to see full writes, a partial write 
and then an error with perror reporting 'No space left on device'. My code exits 
the loop at this point.


Next I tried a simple C++ log4cxx app that writes to the disk and console via a 
MyApp logger. After it fill the disk the app continues to work and continues 
to write to the console. Since the writer is ofstream based, I imagine the bad 
bit was set and further writes just get skipped.


Looking at FileOutputStream::write in svn head I see that if apr_file_write 
doesn't return APR_SUCCESS, it throws an IOException with the write call's 
status. I am not familar enough with the code to see who/what should catch that, 
but to work like 0.9.7 I'd expect it to be caught at some appropriate level to 
disable that particular appender. (Maybe in WriterAppender::append?) If the 
exception is not caught perhaps it is the crash you see.


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: How to config log4cxx to delete the log files periodically

2008-09-22 Thread Jacob L. Anawalt

On 2008-09-19 15:31, Jacob L. Anawalt wrote:
heartedly. This discussion and some recent tweaking of a mail service's 
log rotation (via logrotate) on one server motivated me to figure out 
how to make this work.




I have implemented this in my multi-threaded application by blocking all signals 
I want to respond to before starting any threads, and then starting an async 
signal handler thread to loop on sigwait. When I get a SIGHUP I simply call 
log4cxx::xml::DOMConfigurator::configure(confFile). This makes my program act 
like most daemons where they re-read the config and reopen files on SIGHUP.


This seems to work well, but I am going to review the log4cxx code a little 
closer since it is starting it's own threads, possibly before I block the 
signals. I didn't notice a problem in the single threaded* version using 
sigaction or this multi-threaded one but that could have been chance.


* In log4cxx-hup I was momentarily forgetting that log4cxx was starting it's own 
threads. It almost seems strange that I didn't run into trouble using sigaction.


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: is this an in progress project?

2008-09-12 Thread Jacob L. Anawalt

On 2008-09-12 03:53, somayeh bakhshaei wrote:

i mean is it still in progress.



It is still under active development. 0.10.0 was released in April.

http://logging.apache.org/log4cxx/changes-report.html

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: root node of configuration file

2008-08-19 Thread Jacob L. Anawalt

On 2008-08-19 00:21, Madhu Gowda wrote:

as my configuration file contains some other information also.



Is this possible to keep the root node something other than 
log4j:configuration


You could modify CONFIGURATION_TAG and other code in domconfigurator.cpp and do 
a custom build, but unless only you are going to be dealing with the resulting 
app, and make it clear that it's not following log4j.dtd, it may bite someone in 
the future.


I use multiple configuration files in a configuration directory.

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Is this a bug or user error?

2008-08-15 Thread Jacob L. Anawalt

On 2008-08-15 09:59, Peter Steele wrote:

What's happening is when the rollover occurs at midnight, some processes
still log to the original file, which has now been renamed, whereas


Interesting that some fail to roll over and close the old file handle.


log to the same file, although I've heard that others do this. What's
the solution?



I think it would be better to have individual processes write to a log server, 
either a log4cxx capable one that can read a config file and filter or a dumb 
one, and have a single log server write to the log file.


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: log4cxx server program

2008-08-04 Thread Jacob L. Anawalt

On 2008-08-03 22:37, Mohit Aron wrote:

it'll be nice if the distribution itself provides a server that one can
forward to.



I thought someone asked about a log4cxx native remote server and was told there 
wasn't one, but I can't think of the right key words to find it in the mailing 
list archives. Instead I found an old reference to some SimpleSocketServer [1] 
that would provide the example you are looking for, and the API docs suggesting 
Chainsaw [2].


[1] 
http://mail-archives.apache.org/mod_mbox/logging-log4cxx-dev/200408.mbox/[EMAIL PROTECTED]
[2] 
http://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1net_1_1_socket_appender.html


Hopefully those get you started while waiting on a better answer.

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: How to set a FileAppender to STDOUT?

2008-06-12 Thread Jacob L. Anawalt

Peter Steele wrote:

Our developers can set the log filename through an environment variable.
I wanted to find an option that let them dump their logs to stdout,
simply by using a magic filename, as you can do in log4j...



I see. While lots of development testing options come to my mind from having 
them specify an alternate configuration file to using named pipes and the screen 
program if you can only have one console, none of them include 'System.out'.


I hope you find something workable for your team.

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Log4cxx with VisualC++ 2008 Express Edition - Release issue

2008-06-12 Thread Jacob L. Anawalt

CALOI ROBERTO MARIA wrote:

In the meantime I found the following blog 
http://www.dreamcubes.com/blog/?itemid=43.
It could have saved me a lot of effort.



If you have a moment, perhaps you can add to the MS Developer Studio build 
section of the wiki and include a link to that blog along with some of the more 
important notes in case the blog goes away?


http://wiki.apache.org/logging-log4cxx/MSWindowsBuildInstructions


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: How to set a FileAppender to STDOUT?

2008-06-11 Thread Jacob L. Anawalt

Peter Steele wrote:

Changing to ConsoleAppender isn't an option in our case unfortunately...



Would you mind sharing why it's not an option? I just see the ends of writing to 
stdout and must be missing some critical difference.


Thank you,
--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Using the syslog appender in log4cxx

2008-06-11 Thread Jacob L. Anawalt

Jacob L. Anawalt wrote:

Peter Steele wrote:

Did you specify LOCAL7 as the facility in the config file?


Yes. 


Any luck with this? I will post the full configuration files for syslog and 
log4cxx as well as my sample program if it might help.


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Using the syslog appender in log4cxx

2008-06-09 Thread Jacob L. Anawalt

Dale King wrote:

On Thu, Jun 5, 2008 at 2:00 PM, Peter Steele [EMAIL PROTECTED] wrote:

We're still stuck on 0.9.7, so this may be the motivation we need to
upgrade


0.9.7 does not have the bug I described. Not sure why it wouldn't work
with 0.9.7



I was able to get local7 to work on 0.9.7 using a simple logging test program 
(a.out) and the syslog appender snippet I included earlier. I added a local7 
configuration line to my syslog.conf and reloaded that.


Here are the details and results:

Debian 4.0, liblog4cxx9c2a 0.9.7-6 (log4cxx), bsdutils 1:2.12r-19etch1 (logger), 
sysklogd 1.4.1-18 (syslog)


#syslog.conf:
local7.*/var/log/local7.log

$ logger -p local7.info test
$ ./a.out
$ cat /var/log/local7.log
Jun  9 11:26:08 localhost jacob: test
Jun  9 11:26:35 localhost a.out: 6WARN  root  - 3
Jun  9 11:26:35 localhost a.out: 6WARN  MyApp  - 4

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Using the syslog appender in log4cxx

2008-06-09 Thread Jacob L. Anawalt

Peter Steele wrote:

I was able to get local7 to work on 0.9.7 using a simple logging test
program 

(a.out) and the syslog appender snippet I included earlier. I added a
local7 

configuration line to my syslog.conf and reloaded that.


Did you specify LOCAL7 as the facility in the config file?


Yes. I used logger to verify that only local7.* went to local7.log, and then I 
verified that my simple log4cxx test program's output went to /var/log/daemon 
with DAEMON and to /var/log/local7.log with LOCAL7.


param name=Facility value=LOCAL7 /

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: MDC::put won't overwrite an existing value

2008-04-16 Thread Jacob L. Anawalt

Dale King wrote:

   MDC::put( key, value1 );
   MDC::put( key, value2 );



Without a code example, I must ask; are these MDC::put calls in the same thread 
right next to each other?


The attached program correctly swaps keys in 0.9.7. I don't have an installed 
0.10.0 build handy at the moment.


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026
// g++ appender_threshold.cpp -llog4cxx
#include log4cxx/logger.h
#include log4cxx/xml/domconfigurator.h
//#include log4cxx/propertyconfigurator.h
#include log4cxx/mdc.h

int 
main(void)
{
log4cxx::xml::DOMConfigurator::configure(log4cxx.xml);
//log4cxx::PropertyConfigurator::configure(log4cxx.properties);
log4cxx::LoggerPtr loggerRoot = log4cxx::Logger::getRootLogger();
log4cxx::LoggerPtr loggerApp = log4cxx::Logger::getLogger(MyApp);

log4cxx::MDC::put( key, value1);

LOG4CXX_DEBUG(loggerRoot,1);
LOG4CXX_DEBUG(loggerApp,2);

log4cxx::MDC::put( key, value2);

LOG4CXX_WARN(loggerRoot,3);
LOG4CXX_WARN(loggerApp,4);

if(loggerRoot-isDebugEnabled())
{
loggerRoot-forcedLog(::log4cxx::Level::DEBUG
,Message
,__FILE__
,__LINE__);
}

return EXIT_SUCCESS;
}

?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE log4j:configuration SYSTEM log4j.dtd
log4j:configuration debug=true
	xmlns:log4j=http://jakarta.apache.org/log4j/;

	appender name=CONSOLE class=org.apache.log4j.ConsoleAppender
		param name=Threshold value=WARN/
		layout class=org.apache.log4j.PatternLayout
			param name=ConversionPattern
value=%d{%Y-%m-%d %H:%M:%S} %-5p %c %x - %m %X{key}%n/
		/layout
		filter class=LevelRangeFilter
			param name=AcceptOnMatch value=true/
			param name=LevelMin value=DEBUG /
			param name=LevelMax value=FATAL /
		/filter
	/appender

	root
		level value=ALL/
		appender-ref ref=CONSOLE/
	/root
/log4j:configuration
Threshold =.
Level value for root is [ALL].
OptionConverter::toLevel: no class name specified, level=[ALL]
root level set to ALL
Class name: [org.apache.log4j.ConsoleAppender]
Setting option name=[Threshold], value=[WARN]
Parsing layout of class: org.apache.log4j.PatternLayout
Setting option name=[ConversionPattern], value=[%d{%Y-%m-%d %H:%M:%S} %-5p %c 
%x - %m %X{key}%n]
Setting option name=[AcceptOnMatch], value=[true]
Setting option name=[LevelMin], value=[DEBUG]
OptionConverter::toLevel: no class name specified, level=[DEBUG]
Setting option name=[LevelMax], value=[FATAL]
OptionConverter::toLevel: no class name specified, level=[FATAL]
Adding filter of type [LevelRangeFilter] to appender named [CONSOLE].
Adding appender named [CONSOLE] to logger [root].
2008-04-16 15:30:36 DEBUG root  - 1 value1
2008-04-16 15:30:36 DEBUG MyApp  - 2 value1
2008-04-16 15:30:36 WARN  root  - 3 value2
2008-04-16 15:30:36 WARN  MyApp  - 4 value2
2008-04-16 15:30:36 DEBUG root  - Message value2


Re: [ANNOUNCE] Apache log4cxx 0.10.0 released

2008-04-03 Thread Jacob L. Anawalt

Curt Arnold wrote:
The Apache Logging Services project is happy to announce the release of 
Apache log4cxx 0.10.0.  Apache log4cxx 0.10.0 is the first Apache 
release of log4cxx and is recommended update for all users.


Thank you for your work and patience. I hope to see this in Debian testing soon.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=474138

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Use of operator

2008-03-18 Thread Jacob L. Anawalt

Stephen Bartnikowski wrote:

-Original Message-
From: Josh Kelley [mailto:[EMAIL PROTECTED] 


LOG4CXX_DEBUG(logger, Read   path   and got   out);



Nice. I hadn't tried that since 'message' was documented to expect a string and 
I didn't know if it would break in future versions, so I had written out the 
long form of what the macro wrapped. I will be correcting that shortly.



this:

#define LOGGING_DEBUG(message) { \
   if ((*pLogger)-isDebugEnabled()) {\
  log4cxx::logstream oss(*pLogger, log4cxx::Level::getDebug());\
  oss.setLocation(LOG4CXX_LOCATION);\
  oss  message;\
  oss.end_message();}}

This assumes you have the following declared and initialized:
log4cxx::LoggerPtr* pLogger;



I see that the current online API documentation doesn't use the logstream, and 
have read Curt's response saying it is supported once again. If it hadn't been, 
I was thinking that the current online API docs looked a little more efficient 
for simple strings (which is where I currently use the logging macros), and that 
I would re-implement the older style macros as LS_LOG4CXX_*(logger,streamInput).


I hope the auto-detecting methods work well. If they didn't or again if the 
stream in the macro version hadn't returned and I needed wchar_t support I 
probably would have taken the add a W to the macro name easy way out 
(LSW_LOG4CXX_*(logger,wideStreamInput)).


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Appender filtering

2008-03-04 Thread Jacob L. Anawalt

Jacob L. Anawalt wrote:
I'm going to give the LevelRangeFilter object a go via filter statements 
in an XML config.


This appears to be a very workable solution for my needs. I expect that the 
Threshold option to an Appender is slightly more efficient, but I am not worried 
about it.


Thank you for the your work. I look forward to 0.10 in a future release of 
Debian.
--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Appender filtering

2008-02-29 Thread Jacob L. Anawalt

Jacob L. Anawalt wrote:
I am getting info and debug messages in my system logs. 


I have purchased the log4j manual and it looks like I have the appender 
threshold settings correct.


Here is the output of the attached program and configuration file.

2008-02-29 23:07:12 DEBUG root  - 1
2008-02-29 23:07:12 DEBUG MyApp  - 2
2008-02-29 23:07:12 WARN  root  - 3
2008-02-29 23:07:12 WARN  MyApp  - 4

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026
#include log4cxx/logger.h
#include log4cxx/propertyconfigurator.h

int 
main(void)
{
log4cxx::PropertyConfigurator::configure(log4cxx.properties);
log4cxx::LoggerPtr loggerRoot = log4cxx::Logger::getRootLogger();
log4cxx::LoggerPtr loggerApp = log4cxx::Logger::getLogger(MyApp);

LOG4CXX_DEBUG(loggerRoot,1);
LOG4CXX_DEBUG(loggerApp,2);
LOG4CXX_WARN(loggerRoot,3);
LOG4CXX_WARN(loggerApp,4);

return EXIT_SUCCESS;
}

# A1 is set to be a ConsoleAppender.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{%Y-%m-%d %H:%M:%S} %-5p %c 
%x - %m%n
log4j.appender.CONSOLE.Threshold=WARN;

log4j.rootLogger=ALL, CONSOLE



CategoryApiDocs on Wiki

2008-02-28 Thread Jacob L. Anawalt

Hello,

I've added some pages to the wiki with most of them linked to CategoryApiDocs 
[1]. I would appreciate feedback or corrections (direct to the wiki would be 
nice) from the more experienced log4cxx users. If it seems to be going in an OK 
direction I'll link to the category page from the FrontPage.


[1] http://wiki.apache.org/logging-log4cxx/CategoryApiDocs
--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Seeking documentation

2008-02-27 Thread Jacob L. Anawalt

Curt Arnold wrote:
log4cxx has minimal independent documentation since it attempts to mimic 
log4j.  Unfortunately, log4j also has a gap between the freely available 
intro and the freely available source code.  There are two commercial 
log4j books but they are not products of the Apache Software 
Foundation.  The priority on log4j would be to move on the log4j 2.0 and 
document it during development instead of documenting log4j 1.2 5 years 
or so after initial release.


I am planning on getting the book as a reference and to help other developers 
who may work on my project get up to speed, but I wanted to get slightly deeper 
proof of concept code going before we commit to it.


I wasn't expecting anything new to be written for the older code, just hoping 
others knew of some additional handy resources. I was also wondering if I just 
didn't get it when using the Wiki. When I search I often get results like 7 
results of 704 pages doing a full text search for log4cxx but the title index 
is only 20 pages so I wondered if somehow I was missing something. Maybe it's 
just all the wiki help pages in lots of languages.


At this point I think I'll ask individual questions here when I don't find the 
answer in the archives, and update the wiki when I think I have a nice summary 
to add.


nagoya should be replaced by issues when it refers to JIRA.  Please feel 
free to change those on the Wiki.


I couldn't find eyebrowse anywhere. Maybe it's been replaced by mod_mbox like 
the project mailing lists page links to? If so then I think I have the mailing 
list links set up correctly on the wiki.


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Appender filtering

2008-02-27 Thread Jacob L. Anawalt

Hello,

I want errors = WARN to go to syslog and nothing else that happens to get 
inserted into the log stream so I attempted to use the Threshold option in 
AppenderSkeleton (which my docs show SyslogAppender inheriting from) mentioned 
in FAQ 2.9 [1].


#PropertyConfigurator file
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.SYSLOG=org.apache.log4j.SyslogAppender

log4j.appender.SYSLOG.Threshold=WARN

#layout lines omitted
log4j.rootLogger=WARN, SYSLOG
log4j.logger.MyApp=DEBUG, CONSOLE
log4j.logger.MyApp.MyClass=INFO

I am getting info and debug messages in my system logs. Any suggestions?

(I can't find examples/sort4.lcf mentioned in the FAQ in either the Debian 4.0 
sources for the package or the svn checkout I just did.)


[1] http://logging.apache.org/log4cxx/faq.html#2.9

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Seeking documentation

2008-02-26 Thread Jacob L. Anawalt

Hello,

I'm starting to try log4cxx in a C++ program developed on Debian 4.0 (etch). I 
read the short introduction [1] and then adapted information from there into my 
program. It has been pleasant to have everything so far 'just work'.


I think I am now to the point where I understand everything in the introduction, 
but am not familiar enough with log4cxx, or even log4j, to make the jump from 
the introduction to the doxygen reference. After reading the brief FAQ on the 
wiki, trying for a couple of weeks to hit links to the mailing lists and other 
places pointing to the unresponsive nagoya.apache.org [2,3,4,5], and reading 
log4j articles I feel only slightly closer to my current questions and others 
that loom on the horizon.


Are there any other suggested places to read about implementing, configuring and 
using log4cxx?


Should all the nagaya references be replaced with service names like 
mail-archives or issues? [6]


[1] http://logging.apache.org/log4cxx/manual.html
[2] http://wiki.apache.org/logging-log4cxx/ (link to search user mailing list 
archives)

[3] http://marc.info/?l=log4cxx-userm=114413383713402w=2
[4] http://www.apache.org/dev/machines.html#nagoya
[5] http://monitoring.apache.org/status/
[6] 
http://mail-archives.apache.org/mod_mbox/tomcat-dev/200501.mbox/[EMAIL PROTECTED]


--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026


Re: Seeking documentation

2008-02-26 Thread Jacob L. Anawalt

[EMAIL PROTECTED] wrote:

Try this link -- it's a good tutorial on Log4J -- the concepts apply to
Log4CXX directly:

  http://www.vipan.com/htdocs/log4jhelp.html



Thank you. It was nice to have a list of some of the Appender's 
PropertyConfigurator options.


I am interested in using a SyslogAppender. While wandering though the Doxygen 
output reference I found that the ApenderSkeleton class reference seems to be a 
reasonable place to get the list of appenders available in my version of the 
log4cxx API. Among the classes inheriting from it is SyslogAppender.



What is the fully.qualified.name.of.appender.class?

The intro shows org.apache.log4j.PatternLayout while the log4cxx documentation 
for Appender shows just SyslogAppender or RollingFileAppender. Is just the last 
part of the name parsed? (I suspect that is the reason for bug LOGCXX-102 [1])


[1] http://issues.apache.org/jira/browse/LOGCXX-102

I see all the methods. Where do I look to see what setFacility for example looks 
like in a PropertyConfigurator file? The Appender documentation shows SyslogHost 
being set. Is everything with a get/set method pair a valid option for 
PropertyConfigurator (and possibly the setOption function)?



Where do I learn how to use the DOMConfigurator?

The Doxygen output says there are sample XML files included in the package but I 
can't find them (possibly a Debian package issue if they really were available 
and should have been in the -doc package, or the files really weren't part of 
the package.) The DTD link [2] in the online log4j 1.2 JavaDoc output for the 
DOMConfigurator [3] is broken.


[2] http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/log4j.dtd
[3] http://logging.apache.org/log4j/1.2/apidocs/index.html

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026