Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > INCREDIBLE - NTEventLogAppender.setSource DOESN'T work!!

Reply
Thread Tools

INCREDIBLE - NTEventLogAppender.setSource DOESN'T work!!

 
 
ProgDario
Guest
Posts: n/a
 
      05-04-2005
HI,

I'm using the class NTEventLogAppender in log4j distribution.

My code is simple:

NTEventLogAppender eventLogAppender = new NTEventLogAppender();
eventLogAppender.setSource("ASDF"); // <-- I CHANGE THE SOURCE
eventLogAppender.setLayout(new PatternLayout("%m"));

But when I log into NT system, the source in the event viewer is
'log4j' instead of 'ASDF'.

If I use the constructor NTEventLogAppender("ASDF", layout), the source
becomes 'ASDF', but if I call the setSource method, the source DONESN'T
CHANGE!!

Any idea??

Thanks

ario

 
Reply With Quote
 
 
 
 
Tony Morris
Guest
Posts: n/a
 
      05-04-2005

"ProgDario" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> HI,
>
> I'm using the class NTEventLogAppender in log4j distribution.
>
> My code is simple:
>
> NTEventLogAppender eventLogAppender = new NTEventLogAppender();
> eventLogAppender.setSource("ASDF"); // <-- I CHANGE THE SOURCE
> eventLogAppender.setLayout(new PatternLayout("%m"));
>
> But when I log into NT system, the source in the event viewer is
> 'log4j' instead of 'ASDF'.
>
> If I use the constructor NTEventLogAppender("ASDF", layout), the source
> becomes 'ASDF', but if I call the setSource method, the source DONESN'T
> CHANGE!!
>
> Any idea??
>
> Thanks
>
> ario
>


log4j is open source, why don't you figure it out?
My money is on user error.

--
Tony Morris
Software Engineer, IBM Australia.
BInfTech, SCJP 1.4, SCJD

http://www.jtiger.org/ JTiger Unit Test Framework for J2SE 1.5
http://qa.jtiger.org/ Java Q&A (FAQ, Trivia)
http://xdweb.net/~dibblego/


 
Reply With Quote
 
 
 
 
Alun Harford
Guest
Posts: n/a
 
      05-04-2005

"ProgDario" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> HI,
>
> I'm using the class NTEventLogAppender in log4j distribution.
>
> My code is simple:
>
> NTEventLogAppender eventLogAppender = new NTEventLogAppender();
> eventLogAppender.setSource("ASDF"); // <-- I CHANGE THE SOURCE
> eventLogAppender.setLayout(new PatternLayout("%m"));
>
> But when I log into NT system, the source in the event viewer is
> 'log4j' instead of 'ASDF'.
>
> If I use the constructor NTEventLogAppender("ASDF", layout), the source
> becomes 'ASDF', but if I call the setSource method, the source DONESN'T
> CHANGE!!
>


Groan.
Recompile your .class file with the new source.

Alun Harford


 
Reply With Quote
 
Joona I Palaste
Guest
Posts: n/a
 
      05-04-2005
ProgDario <(E-Mail Removed)> scribbled the following:
> HI,


> I'm using the class NTEventLogAppender in log4j distribution.


> My code is simple:


> NTEventLogAppender eventLogAppender = new NTEventLogAppender();
> eventLogAppender.setSource("ASDF"); // <-- I CHANGE THE SOURCE
> eventLogAppender.setLayout(new PatternLayout("%m"));


> But when I log into NT system, the source in the event viewer is
> 'log4j' instead of 'ASDF'.


> If I use the constructor NTEventLogAppender("ASDF", layout), the source
> becomes 'ASDF', but if I call the setSource method, the source DONESN'T
> CHANGE!!


> Any idea??


I had a look at the NTEventLogAppender source. Here is the constructor
NTEventLogAppender(String, String, Layout) which all other constructors
call:

public NTEventLogAppender(String server, String source, Layout layout)
{
if (source == null) {
source = "Log4j";
}
if (layout == null) {
this.layout = new TTCCLayout();
} else {
this.layout = layout;
}

try {
_handle = registerEventSource(server, source);
} catch (Exception e) {
e.printStackTrace();
_handle = 0;
}
}

Here is the method setSource(String):

public
void setSource(String source) {
this.source = source.trim();
}

Notice that it does NOT call registerEventSource(server, source),
whatever that does.

However, looking at the method activateOptions() we find:

public
void activateOptions() {
if (source != null) {
try {
_handle = registerEventSource(server, source);
} catch (Exception e) {
LogLog.error("Could not register event source.", e);
_handle = 0;
}
}
}

So maybe you'll have to call that after calling setSource(). Just a
guess, I don't have a Windows NT machine to test it on, and I don't
intend to get one.

--
/-- Joona Palaste ((E-Mail Removed)) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"Life without ostriches is like coffee with milk."
- Mika P. Nieminen
 
Reply With Quote
 
ProgDario
Guest
Posts: n/a
 
      05-05-2005
THANKS Joona!!

You were right, I solved the problem!!

I also looked at the source but with no enough attention............


Thanks again


ario

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Incredible JPrintout Christmas Discount - 75% !!! Only 49.95 for professional java reporting package with support. support@jprintout.com Java 0 11-17-2005 09:27 PM
Incredible JPrintout Christmas Discount - 75% !!! Only 49.95 for professional java reporting package with support support@jprintout.com Java 0 11-17-2005 09:17 PM
The Incredible Disappearing Table Row Pathogenix@gmail.com ASP .Net 0 05-06-2005 03:16 PM
Just see this...It`s incredible! Arondelle HTML 2 07-07-2004 03:00 AM
[email] Incredible .body on that woman,,,wow!! hmifhr yybes Flying Rat Computer Support 1 12-22-2003 07:55 PM



Advertisments