aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Logging in assignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Logging in assignment" Watch "Logging in assignment" New topic
Author

Logging in assignment

Pawel Poltorak
Ranch Hand

Joined: Sep 21, 2005
Posts: 36
Howdy all ranchers,

I am currently thinking through configuration of logger and planning to use 'java.util.logging.config.class' java property and programatically configure logger. Do you think it's a good idea.

Another thing, is it OK to set certain java properties on runtime using System.setProperty(). I'm thinking about 'java.util.logging.config.class' but also 'java.rmi.server.codebase' which is needed for RMI. Instructions say that we cannot use command line for this, so I think there is no other option.

Best Regards,
Pawel


SCJP, SCJD
Surya De
Greenhorn

Joined: Nov 06, 2005
Posts: 28
I would like that question answered as well. I am rather confused with the RMI myself because this is the first time I have programmed using that framework. I understand the overall idea but I think I am doing something fundamentally wrong resulting in a very annoying exception.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11526
    
100

Hi Pawel,
I am currently thinking through configuration of logger and planning to use 'java.util.logging.config.class' java property and programatically configure logger. Do you think it's a good idea.
I think it may be a bit of overkill. But it should be OK I guess.
Another thing, is it OK to set certain java properties on runtime using System.setProperty(). I'm thinking about 'java.util.logging.config.class' but also 'java.rmi.server.codebase' which is needed for RMI. Instructions say that we cannot use command line for this, so I think there is no other option.
If you start the RMI Registry programattically (look at the java.rmi.registry.LocateRegistry class) then there is no need to specify the codebase. Which will allow you to do the simplest thing that works and will get you full marks . However I personally did the same thing in my submission so that the server could still start even if an RMI Registry had been started externally (but my assignment did not have the warning against going beyond the requirements, and so I went way beyond the requirements.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Pawel Poltorak
Ranch Hand

Joined: Sep 21, 2005
Posts: 36
Thank you for answer Andrew,

I think it may be a bit of overkill. But it should be OK I guess.


You mean that I should just write a method that will be invoked upon program startup and configure the logger?

I also start RMI programattically, however I also allow external instance of rmiregistry. But I'd gladly drop that idea, because I feel that it might cause some trouble, which could have impact on my mark. Do you think that implementing only programattical solution and documenting it in choices.txt and user guide will be sufficient?

Best Regards,
Pawel
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11526
    
100

Hi Pawel,

You mean that I should just write a method that will be invoked upon program startup and configure the logger?
Yes, that is what I meant.

However I am having second thoughts about it now. My initial thoughts were based around the standard way of using "java.util.logging.config.class" (having that class read your own file and process it in your own manner), and I was unsure about using it in a non-standard manner (you are not reading in a file); and I didn't see what it would gain you. But on further thought I can see that implementing it will give you a standard common place to enhance your logging configuration later.

So, ummm, I take it back - your original way is fine.

I also start RMI programattically, however I also allow external instance of rmiregistry. But I'd gladly drop that idea, because I feel that it might cause some trouble, which could have impact on my mark. Do you think that implementing only programattical solution and documenting it in choices.txt and user guide will be sufficient?
Absolutely! From what I've seen, most candidates don't even try to work out how to connect to a running RMI Registry.

Regards, Andrew
Pawel Poltorak
Ranch Hand

Joined: Sep 21, 2005
Posts: 36
Thanks for your answer Andrew,

I'll remove the connecting to existing rmiregistry then.

Best Regards,
Pawel
Andy Michalec
Greenhorn

Joined: Jan 15, 2006
Posts: 5
I am also using 'java.util.logging' but I have choosen following approach:
1) I have created 'logging.properties' configuration file with tuned options
2) My ant building script places config in runme.jar at some place
3) At early stages of application running logging mechanism is instructed to load this config from jar provided user had not set his/her own configuration;
code snippet below:

try {
if (System.getProperty("java.util.logging.config.file") == null) {
// if there is no configuration set in environment
// jar class loader should take defaults from jar
InputStream is = getClass().getResourceAsStream(
"/path/inside/jar/file/logging.properties");
LogManager.getLogManager().readConfiguration(is);
}
} catch (IOException e) {
...
}

This is much simpler then programmatic manipulation

cheers,
andy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logging in assignment