Java Logging Question

R

Rhino

I'm wrestling with a challenging problem involving the java.util.logging
code, specifically a condition discussed in Bug ID 6244047. Something that
might help me a lot is some information about some code used in the
logging.properties file found in JRE/lib.

Referring specifically to the logging.properties file in a Java 6 JDK, one
of the lines says:

java.util.logging.FileHandler.pattern = %h/java%u.log

It would appear that %h and %u in the preceding line are variables but I am
at a loss to understand what values they have or where those values are
set. Can anyone clue me in?

The comment above that line says only that the "default file output in the
user's home directory" but I'm not clear on whether they are referring to
OS home directory (I'm using Windows XP SP2) or the Java home directory.
It's also possible that the values of %h and %u may be getting overridden
inappropriately somewhere, even if they were set correctly in the first
place, so I'd like to know how %h and %u are being set and where they might
be getting overridden.

I hope someone more familiar with java logging can clue me in. That should
enable me to solve the bigger problem myself or at least rule out the most
obvious suspect.
 
M

markspace

Rhino said:
The comment above that line says only that the "default file output in the
user's home directory"

User's home directory! Like /usr/rhino or C:\Users\Rhino or /home/rhino.
 
T

Tom Anderson

User's home directory! Like /usr/rhino or C:\Users\Rhino or /home/rhino.

Is there anywhere it would be /usr/rhino?

On OS X, it would be /Users/Rhino, FWIW. On unix systems configured for
large numbers of users, it might well be /home/r/rhino (it's broken up
alphabetically). On unix systems which organise users by primary group
(and there are some), it would be /home/pachyderms/rhino. All of which is
useless information, of which i am a veritable mine.

More importantly, why on earth is java writing logs to home directories?
That's dreadful behaviour!

tom
 
A

Arne Vajhøj

I'm wrestling with a challenging problem involving the java.util.logging
code, specifically a condition discussed in Bug ID 6244047. Something that
might help me a lot is some information about some code used in the
logging.properties file found in JRE/lib.

Referring specifically to the logging.properties file in a Java 6 JDK, one
of the lines says:

java.util.logging.FileHandler.pattern = %h/java%u.log

It would appear that %h and %u in the preceding line are variables but I am
at a loss to understand what values they have or where those values are
set. Can anyone clue me in?

They are described in:

http://java.sun.com/javase/6/docs/api/java/util/logging/FileHandler.html
The comment above that line says only that the "default file output in the
user's home directory" but I'm not clear on whether they are referring to
OS home directory (I'm using Windows XP SP2) or the Java home directory.
It's also possible that the values of %h and %u may be getting overridden
inappropriately somewhere, even if they were set correctly in the first
place, so I'd like to know how %h and %u are being set and where they might
be getting overridden.

The above link says:

"%h" the value of the "user.home" system property

so it is OS home directory.

Arne
 
A

Arne Vajhøj

Is there anywhere it would be /usr/rhino?

On OS X, it would be /Users/Rhino, FWIW. On unix systems configured for
large numbers of users, it might well be /home/r/rhino (it's broken up
alphabetically). On unix systems which organise users by primary group
(and there are some), it would be /home/pachyderms/rhino. All of which
is useless information, of which i am a veritable mine.

More importantly, why on earth is java writing logs to home directories?
That's dreadful behaviour!

If it has to pick a directory that:
- is known to exist
- where the app has write permission
- where files does not get deleted
- conceptually will exist on all platforms (or at least as many as possible)
then what would you suggest?

Arne
 
L

Lew

M

markspace

Lew said:
On Windows it's
"C:\Documents and Settings\lewbloch".


To me, the "OS home directory" on windows is C:\Windows (drive letter
may vary). I think I see what you an Arne are saying, it's just that
the phrase "OS home directory" struck me as something different, and I
thought I'd clear up any possibility of confusion.

I guess my answer to "Is there a difference?" is that yes, the two
phrases are certainly different ("OS home" vs. "user's home") and could
be construed to mean different things.
 
L

Lew

markspace said:
To me, the "OS home directory" on windows is C:\Windows (drive letter
may vary). I think I see what you an Arne are saying, it's just that
the phrase "OS home directory" struck me as something different, and I
thought I'd clear up any possibility of confusion.

This is the first time in my decades in the profession I've heard the phrase
"OS home directory", and certainly the first I've heard "C:\Windows" referred
to as any kind of "home" directory. I have only ever heard "home directory"
used as defined in
I guess my answer to "Is there a difference?" is that yes, the two
phrases are certainly different ("OS home" vs. "user's home") and could
be construed to mean different things.

Your usage is idiolectic.
 
R

Rhino

User's home directory! Like /usr/rhino or C:\Users\Rhino or
/home/rhino.

Thank you! I wasn't clear if this was an OS home directory or a Jaav home
directory (or some other kind of home directory). You got me going in the
right direction.

As it turns out, the variables in the pattern are described in the
FileHandler API. This tells me that %h represents the Java system property
"user.home", which is c:\Documents and Settings\Rhino in my case. (I'm just
adding this information in case anyone down the road has the same issue.)

I couldn't for the life of me remember where the variables in the pattern
were documented and was disappointed to find the meanings not mentioned in
the logging.properties file itself. Second best would have been a note in
logging.properties telling me to look in the FileHandler API.

Thanks again!
 
R

Rhino

Is there anywhere it would be /usr/rhino?


More importantly, why on earth is java writing logs to home
directories? That's dreadful behaviour!
It may be dreadful behaviour but %h does indeed stand for the value
obtained from System.getProperty("user.home"). That is a bit unexpected
from my point of view too but what can you do?
 
L

Lew

Tom Anderson wrote
More importantly, why on earth is java [sic] writing logs to home
directories? That's dreadful behaviour!
It may be dreadful behaviour but %h does indeed stand for the value
obtained from System.getProperty("user.home"). That is a bit unexpected
from my point of view too but what can you do?
If it [Java] has to pick a directory that:
- is known to exist
- where the app has write permission
- where files does not get deleted
- conceptually will exist on all platforms (or at least as many as
possible)
then what would you suggest?
 
L

Lew

Rhino said:
As it turns out, the variables in the pattern are described in the
FileHandler API. This tells me that %h represents the Java system property

As it turns out, Arne Vajhøj wrote, approximately eleven hours earlier:
Rhino continued:
"user.home", which is c:\Documents and Settings\Rhino in my case. (I'm just
adding this information in case anyone down the road has the same issue.)

As was posted upthread:
I couldn't for the life of me remember where the variables in the pattern
were documented and was disappointed to find the meanings not mentioned in
the logging.properties file itself. Second best would have been a note in
logging.properties telling me to look in the FileHandler API.

Excellent point.
 
T

Tom Anderson

If it has to pick a directory that:
- is known to exist
- where the app has write permission
- where files does not get deleted
- conceptually will exist on all platforms (or at least as many as possible)
then what would you suggest?

I'd suggest those assumptions are wrong. A library has no business
deciding to write logs anywhere on disk at all; it should write logs where
i tell it to, and only when i tell it to. If it has to log and i haven't
told it to write to a file, it should write to syserr.

tom

--
Formal logical proofs, and therefore programs - formal logical proofs
that particular computations are possible, expressed in a formal system
called a programming language - are utterly meaningless. To write a
computer program you have to come to terms with this, to accept that
whatever you might want the program to mean, the machine will blindly
follow its meaningless rules and come to some meaningless conclusion. --
Dehnadi and Bornat
 
T

Tom Anderson

It may be dreadful behaviour but %h does indeed stand for the value
obtained from System.getProperty("user.home"). That is a bit unexpected
from my point of view too but what can you do?

Moan about is on newsgroups, that's what!

tom

--
Formal logical proofs, and therefore programs - formal logical proofs
that particular computations are possible, expressed in a formal system
called a programming language - are utterly meaningless. To write a
computer program you have to come to terms with this, to accept that
whatever you might want the program to mean, the machine will blindly
follow its meaningless rules and come to some meaningless conclusion. --
Dehnadi and Bornat
 
T

Tom Anderson

This is the first time in my decades in the profession I've heard the
phrase "OS home directory", and certainly the first I've heard
"C:\Windows" referred to as any kind of "home" directory. I have only
ever heard "home directory" used as defined in
<http://en.wikipedia.org/wiki/Home_directory>

It's not an unreasonable leap to refer to the directory named by the
JAVA_HOME environment variable as the 'Java home directory'. Ditto for
ANT_HOME, JBOSS_HOME, and various other _HOMEs you may have.

You could generalise that to referring to the system folder as the OS
home. Although as you observed, people don't actually say that.
Your usage is idiolectic.

Yours is homodoxian.

tom

--
Formal logical proofs, and therefore programs - formal logical proofs
that particular computations are possible, expressed in a formal system
called a programming language - are utterly meaningless. To write a
computer program you have to come to terms with this, to accept that
whatever you might want the program to mean, the machine will blindly
follow its meaningless rules and come to some meaningless conclusion. --
Dehnadi and Bornat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top