• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Logging in assignment

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Pawel Poltorak
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your answer Andrew,

I'll remove the connecting to existing rmiregistry then.

Best Regards,
Pawel
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic