You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by T Master <tm...@iknowledgeinc.com> on 2002/01/04 23:03:36 UTC

Turning a Category On/Off

Apologies for dumb questions...

I am trying to dynamiccally modify my Category's Priority at run time.

The code below is used to effect this:
            myCategory.setPriority(Priority.INFO);  // Turn ON
            myCategory.setPriority(Priority.DEBUG);  // Turn OFF


However, after turning my Category OFF , messages logged at the info level
still appear in my File.

I believe I'm doing somethign really stupid or should not be using DEBUG as
my OFF equivilant.


T Master


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Getting a good user experience on Windows?

Posted by Scott Farquhar <sc...@atlassian.com>.
If you are dealing with users, and across platforms, you may want to use 
java webstart (http://java.sun.com/products/javawebstart/).

It allows for GUI starting of programs (but won't help with any of your 
problems).

Also - javaw starts programs in the background, whilst java starts in 
the foreground.

Good luck with your project.

Scott

Bob Jacobsen wrote:

> Thanks for the quick reply!
> 
> At 4:53 PM +1100 1/5/02, Scott Farquhar wrote:
> 
>> a.  This occurs from the default windows installation running jar
>> files with "javaw -jar xxx.jar".  You wish to change this to be
>> "java -jar xxx.jar".
>>
>> This is a registry setting (from memory), so this would not be an
>> easy fix for your users.
>>
>> You could make a batch file (".bat") or command file (".cmd") to
>> do a windows only startup if you wished.
>>
>> Another option is to use chainsaw or
>> Lumbermill (http://jakarta.apache.org/log4j/docs/download.html) to
>> view log files (ie log to a socket).  Or you can use a file appender
>> and just tail the log file somewhere?
> 
> 
> Thanks for the pointers; I didn't understand the difference between the 
> two methods of starting e.g. java/javaw, but with that clue I think I 
> can track it down.  A command file sounds like the right solution then.
> 
>> b. Which version of log4j are you using?  In log4j alpha 5, and 1.1.3, 
>> this is the line that gets the line separator:
>>
>> (Layout.java)
>>   public final static String LINE_SEP = 
>> System.getProperty("line.separator");
>>
>> So the line separator should be correct for your system.
> 
> 
> Another great clue!  On the machines where people are complaining, that 
> is just returning the single linefeed!  That's probably due to a busted 
> Java install, which seems depressingly common on user machines.  I can 
> probably track that down...
> 
>> What project are you working on?
> 
> 
> Its a program for model railroads: http://sourceforge.net/projects/jmri/ 
> and http://jmri.sourceforge.net/   It makes it (somewhat) easier for 
> hobbyists to automate the signals, etc, on a model railroad.  Having a 
> powerful logging system like Log4J helps, because these people really 
> don't want to dig in with a debugger.  Following a trace-like output 
> from a log is much more understandable to them.
> 
> Thanks again for the help, I'll post a summary when I get it figured out.
> 
> Bob


-- 
Scott Farquhar :: scott@atlassian.com

Atlassian :: http://www.atlassian.com
      Supporting YOUR J2EE World



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Getting a good user experience on Windows?

Posted by Bob Jacobsen <Bo...@lbl.gov>.
Thanks for the quick reply!

At 4:53 PM +1100 1/5/02, Scott Farquhar wrote:
>a.  This occurs from the default windows installation running jar
>files with "javaw -jar xxx.jar".  You wish to change this to be
>"java -jar xxx.jar".
>
>This is a registry setting (from memory), so this would not be an
>easy fix for your users.
>
>You could make a batch file (".bat") or command file (".cmd") to
>do a windows only startup if you wished.
>
>Another option is to use chainsaw or
>Lumbermill (http://jakarta.apache.org/log4j/docs/download.html) to
>view log files (ie log to a socket).  Or you can use a file appender
>and just tail the log file somewhere?

Thanks for the pointers; I didn't understand the difference between 
the two methods of starting e.g. java/javaw, but with that clue I 
think I can track it down.  A command file sounds like the right 
solution then.

>b. Which version of log4j are you using?  In log4j alpha 5, and 
>1.1.3, this is the line that gets the line separator:
>
>(Layout.java)
>   public final static String LINE_SEP = System.getProperty("line.separator");
>
>So the line separator should be correct for your system.

Another great clue!  On the machines where people are complaining, 
that is just returning the single linefeed!  That's probably due to a 
busted Java install, which seems depressingly common on user 
machines.  I can probably track that down...

>What project are you working on?

Its a program for model railroads: 
http://sourceforge.net/projects/jmri/ and 
http://jmri.sourceforge.net/   It makes it (somewhat) easier for 
hobbyists to automate the signals, etc, on a model railroad.  Having 
a powerful logging system like Log4J helps, because these people 
really don't want to dig in with a debugger.  Following a trace-like 
output from a log is much more understandable to them.

Thanks again for the help, I'll post a summary when I get it figured out.

Bob
-- 
--------------
Bob Jacobsen (Bob_Jacobsen@lbl.gov, 510-486-7355, fax 510-495-2957)

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Getting a good user experience on Windows?

Posted by Scott Farquhar <sc...@atlassian.com>.
a.  This occurs from the default windows installation running jar files 
with "javaw -jar xxx.jar".  You wish to change this to be "java -jar 
xxx.jar".

This is a registry setting (from memory), so this would not be an easy 
fix for your users.

You could make a batch file (".bat") or command file (".cmd") to do a 
windows only startup if you wished.

Another option is to use chainsaw or Lumbermill 
(http://jakarta.apache.org/log4j/docs/download.html) to view log files 
(ie log to a socket).  Or you can use a file appender and just tail the 
log file somewhere?

b. Which version of log4j are you using?  In log4j alpha 5, and 1.1.3, 
this is the line that gets the line separator:

(Layout.java)
   public final static String LINE_SEP = 
System.getProperty("line.separator");

So the line separator should be correct for your system.

What project are you working on?

Cheers,
Scott

Bob Jacobsen wrote:

> I've been using Log4J on a Linux/Macintosh project for a while, with 
> much success.  But I've started to get some Windows users (esp. Win98, 
> which seems to be quite popular among my hobbyist users), and they're 
> not happy.
> 
> I'd like some advice on how to solve two problems.
> 
> I'm using a ConsoleAppender and a FileAppender, generally configured as:
> 
>   log4j.appender.A1=org.apache.log4j.ConsoleAppender
>   log4j.appender.A1.layout=org.apache.log4j.PatternLayout
>   log4j.appender.A1.layout.ConversionPattern=%6r %-37.37c{2} %-5p - %m 
> [%t]%n
> 
>   log4j.appender.R=org.apache.log4j.FileAppender
>   log4j.appender.R.File=example.log
>   log4j.appender.R.layout=org.apache.log4j.PatternLayout
>   log4j.appender.R.layout.ConversionPattern=%6r %-37.37c{2} %-5p - %m 
> [%t]%n
> 
> There's no other configuration information defined; I'm really hoping 
> that somebody will tell me the magic words to fix two problems:
> 
> a) Seeing the ConsoleAppender.
> 
> On the Mac and Linux, standard output is conveniently available in a 
> window.  On Windows, when you start the application by clicking on the 
> .jar file, the logging standard output doesn't seem to go anywhere; I 
> certainly haven't found it.  The only way I've seen to get the 
> ConsoleAppender output is to open a DOS window and run from the DOS 
> prompt.  But this really isn't a good user experience, to say the least.
> 
> Does anybody know a better way to handle this on Win95/98 etc?
> 
> b) The FileAppender creates files that are inconvenient to look at.
> 
> Apparently, the most common way to look at a text file on Windows is 
> with the Notepad application, and it insists that line should end with 
> _both_ a CR (0x0D) and LF (0x0A) character!!  It certainly possible to 
> open with files with a source-file editor, but not everybody has one.  
> As configured, Log4J's FileAppender puts only the LF on Win95/98.  This 
> is really Not A Problem on Linux or the Macintosh, but again is a real 
> hassle for users.
> 
> Can anybody suggest solutions to these? Preferably cross-platform ones?
> 
> Thanks in advance.
> 
> Bob


-- 
Scott Farquhar :: scott@atlassian.com

Atlassian :: http://www.atlassian.com
      Supporting YOUR J2EE World



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Getting a good user experience on Windows?

Posted by Deacon Marcus <de...@wwtech.pl>.
Hi,

> -----Original Message-----
> From: Bob Jacobsen [mailto:Bob_Jacobsen@lbl.gov]
> Sent: Saturday, January 05, 2002 6:34 AM
> To: Log4J Users List
> Subject: Getting a good user experience on Windows?
>
>
> I've been using Log4J on a Linux/Macintosh project for a while, with
> much success.  But I've started to get some Windows users (esp.
> Win98, which seems to be quite popular among my hobbyist users), and
> they're not happy.
>
> I'd like some advice on how to solve two problems.
>
> I'm using a ConsoleAppender and a FileAppender, generally configured as:
>
>    log4j.appender.A1=org.apache.log4j.ConsoleAppender
>    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
>    log4j.appender.A1.layout.ConversionPattern=%6r %-37.37c{2}
> %-5p - %m [%t]%n
>
>    log4j.appender.R=org.apache.log4j.FileAppender
>    log4j.appender.R.File=example.log
>    log4j.appender.R.layout=org.apache.log4j.PatternLayout
>    log4j.appender.R.layout.ConversionPattern=%6r %-37.37c{2} %-5p
> - %m [%t]%n
>
> There's no other configuration information defined; I'm really hoping
> that somebody will tell me the magic words to fix two problems:
>
> a) Seeing the ConsoleAppender.
>
> On the Mac and Linux, standard output is conveniently available in a
> window.  On Windows, when you start the application by clicking on
> the .jar file, the logging standard output doesn't seem to go
> anywhere; I certainly haven't found it.  The only way I've seen to
> get the ConsoleAppender output is to open a DOS window and run from
> the DOS prompt.  But this really isn't a good user experience, to say
> the least.
>
> Does anybody know a better way to handle this on Win95/98 etc?

Basically you need to substitute javaw.exe with java.exe. The difference is,
practically, that java.exe gives you dos-like window while javaw.exe runs
"invisible".
Fix: open regedit.exe, check HKEY_CLASSES_ROOT/.jar - it should have a
"(default)" value "jarfile". Check HKEY_CLASSES_ROOT/jarfile - it should
have something like /shell/open/command/ "(default" = "C:\Program
Files\JavaSoft\JRE\1.4\bin\javaw.exe -jar %1" - change to "C:\Program
Files\JavaSoft\JRE\1.4\bin\java.exe -jar %1". You can now select
HKEY_CLASSES_ROOT/jarfile in the tree panel and tell it to "export"
"selected branch" "HKEY_CLASSES_ROOT\jarfile\" to a file - you can now give
that file to your users to install on their machines (double click on .reg
file is enough), if they have the same version (I believe the setting looks
the same for versions 1.2-1.4, so you can manually edit the .reg file to
create 1.2, 1.3, 1.4 versions).

> b) The FileAppender creates files that are inconvenient to look at.
>
> Apparently, the most common way to look at a text file on Windows is
> with the Notepad application, and it insists that line should end
> with _both_ a CR (0x0D) and LF (0x0A) character!!  It certainly
> possible to open with files with a source-file editor, but not
> everybody has one.  As configured, Log4J's FileAppender puts only the
> LF on Win95/98.  This is really Not A Problem on Linux or the
> Macintosh, but again is a real hassle for users.

WordPad is perfectly ok with unix line endings. Just change the assignation
from .log (or whatever) -> notepad.exe to .log -> wordpad.exe. You can use
"folder options" from explorer or registry again. If you go for registry,
you need to change "HKEY_CLASSES_ROOT\txtfile\shell\open\command"
"(default)" from "C:\WINDOWS\NOTEPAD.EXE %1" to "C:\WINDOWS\WORDPAD.EXE %1",
just "WORDPAD.EXE %1" should work also. Same for
"HKEY_CLASSES_ROOT\txtfile\shell\print\command" "(default)" from
"C:\WINDOWS\NOTEPAD.EXE /p %1" to "C:\WINDOWS\WORDPAD.EXE /p %1" or
"WORDPAD.EXE /p %1" (not sure if it'll work with right-click printing).
Again, you can just export the .reg file and tell your users to install it.

Both are quick-fixes from my 98 SE machine, it could be different on
different kinds of Win32 (I'm not sure how about NT-line - 95 line have it
as above from 95 to ME).

>
> Can anybody suggest solutions to these? Preferably cross-platform ones?
>
> Thanks in advance.
>
> Bob
> --
> --------------
> Bob Jacobsen (Bob_Jacobsen@lbl.gov, 510-486-7355, fax 510-495-2957)

Hope this helps, greetings,
     deacon Marcus

~~~~~
HELP STARVING JAVA PROGRAMMER: If you need cheap and reliable JSP hosting,
please contact deacon_marcus@wwtech.pl (from 12$/m for 50mb WWW + 20mb mail)


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Getting a good user experience on Windows?

Posted by Bob Jacobsen <Bo...@lbl.gov>.
I've been using Log4J on a Linux/Macintosh project for a while, with 
much success.  But I've started to get some Windows users (esp. 
Win98, which seems to be quite popular among my hobbyist users), and 
they're not happy.

I'd like some advice on how to solve two problems.

I'm using a ConsoleAppender and a FileAppender, generally configured as:

   log4j.appender.A1=org.apache.log4j.ConsoleAppender
   log4j.appender.A1.layout=org.apache.log4j.PatternLayout
   log4j.appender.A1.layout.ConversionPattern=%6r %-37.37c{2} %-5p - %m [%t]%n

   log4j.appender.R=org.apache.log4j.FileAppender
   log4j.appender.R.File=example.log
   log4j.appender.R.layout=org.apache.log4j.PatternLayout
   log4j.appender.R.layout.ConversionPattern=%6r %-37.37c{2} %-5p - %m [%t]%n

There's no other configuration information defined; I'm really hoping 
that somebody will tell me the magic words to fix two problems:

a) Seeing the ConsoleAppender.

On the Mac and Linux, standard output is conveniently available in a 
window.  On Windows, when you start the application by clicking on 
the .jar file, the logging standard output doesn't seem to go 
anywhere; I certainly haven't found it.  The only way I've seen to 
get the ConsoleAppender output is to open a DOS window and run from 
the DOS prompt.  But this really isn't a good user experience, to say 
the least.

Does anybody know a better way to handle this on Win95/98 etc?

b) The FileAppender creates files that are inconvenient to look at.

Apparently, the most common way to look at a text file on Windows is 
with the Notepad application, and it insists that line should end 
with _both_ a CR (0x0D) and LF (0x0A) character!!  It certainly 
possible to open with files with a source-file editor, but not 
everybody has one.  As configured, Log4J's FileAppender puts only the 
LF on Win95/98.  This is really Not A Problem on Linux or the 
Macintosh, but again is a real hassle for users.

Can anybody suggest solutions to these? Preferably cross-platform ones?

Thanks in advance.

Bob
-- 
--------------
Bob Jacobsen (Bob_Jacobsen@lbl.gov, 510-486-7355, fax 510-495-2957)

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Turning a Category On/Off

Posted by T Master <tm...@iknowledgeinc.com>.
After setting my logger to DEBUG to stop info() messages, I am still getting
output.
Anyone have ideas why please?

Below are some clear details on code, stdout, and file output.


Code:
        System.out.println("********** UPDATE SUCCESS -> OFF");
        ejbSuccess.setPriority(Priority.DEBUG);
        ejbSuccess.info("********** UPDATE SUCCESS -> OFF");
        System.out.println("********** success is " +
ejbSuccess.getChainedPriority().toString() );

Console Output:
********** UPDATE SUCCESS -> OFF
********** success is DEBUG


My File contains:
********** UPDATE SUCCESS -> OFF



T Master


----- Original Message -----
From: "T Master" <tm...@iknowledgeinc.com>
To: <lo...@jakarta.apache.org>
Sent: Friday, January 04, 2002 3:03 PM
Subject: Turning a Category On/Off


>
> Apologies for dumb questions...
>
> I am trying to dynamiccally modify my Category's Priority at run time.
>
> The code below is used to effect this:
>             myCategory.setPriority(Priority.INFO);  // Turn ON
>             myCategory.setPriority(Priority.DEBUG);  // Turn OFF
>
>
> However, after turning my Category OFF , messages logged at the info level
> still appear in my File.
>
> I believe I'm doing somethign really stupid or should not be using DEBUG
as
> my OFF equivilant.
>
>
> T Master



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>