Hello
Thanks for the help. It sort of works... it logs to the "Application
Log" if I use a pre-existing source (? not sure of the win32
terminology. It's all ass-backwards in my mind). It logs to a custom
source to a custom log. But it refuses to log to a custom source in
an existing log.
Either way, I've been slamming my ham with this (win32 specific)
problem since Saturday and I give up. There's a reason why I avoid
Windows like the damn plague.
Kudos on the library over all.
Vic
On Nov 27, 2007 11:19 AM, Curt Arnold <[EMAIL PROTECTED]> wrote:
>
> On Nov 26, 2007, at 9:08 PM, Vic Simkus wrote:
>
> > Hello
> >
> > I'm trying to programmatically configure the NT event log appender and
> > having zero luck. Everything compiles but there are no entries in the
> > event viewer. Bellow is the code. What am I missing here?
> >
> > log4cxx::nt::NTEventLogAppender * ntAppender = new
> > log4cxx::nt::NTEventLogAppender();
> > ntAppender->setSource(L"Source");
> > ntAppender->setName(L"ntlogappender");
> > ntAppender->setLayout(log4cxx::LayoutPtr(new
> > log4cxx::SimpleLayout()));
> >
>
> log4cxx::helpers::Pool p;
> ntAppender->activateOptions(p);
>
> > log4cxx
> > ::BasicConfigurator::configure(log4cxx::AppenderPtr(ntAppender));
> > log4cxx::Logger::getRootLogger()-
> > >setLevel(log4cxx::Level::getDebug());
> > logger = log4cxx::Logger::getLogger("logger");
> >
> > LOG4CXX_INFO(logger,"Created NTEventLogAppender contingency
> > appender");
> >
> >
> >
>
>
> When programmatically configuring appenders, layouts, etc,
> activateOptions should be called after configuration. You should have
> gotten a console message "NT Event Log not opened".
>
> Some stylistic issues:
>
> When calling methods that take LogString with string literals, you
> should enclose them in LOG4CXX_STR instead of prefixing with L., like:
>
> >
> > ntAppender->setSource(LOG4CXX_STR("Source"));
> > ntAppender->setName(LOG4CXX_STR("ntlogappender"));
>
> L is only appropriate when logchar is wchar_t (typical on Windows),
> but would be inappropriate when logchar is char (typical on Unix).
> Obviously, it is a bigger deal when you are using a logger that is not
> platform specific.
>
> Using raw pointers is atypical, I would have done
>
> > log4cxx::nt::NTEventLogAppenderPtr ntAppender(new
> > log4cxx::nt::NTEventLogAppender());
>