Forums Register Login

Logging in assignment

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Thanks for your answer Andrew,

I'll remove the connecting to existing rmiregistry then.

Best Regards,
Pawel
+Pie Number of slices to send: Send
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
Evacuate the building! Here, take this tiny ad with you:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 940 times.
Similar Threads
why we use logger instance as a static in java(Priorty urgent)
Logging into multiple files.
Hierarchical logging
HTML Writer for a web project.
Logger and assertions
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 22:28:02.