aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Logger 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 "Logger" Watch "Logger" New topic
Author

Logger

John Stark
Ranch Hand

Joined: Jul 19, 2011
Posts: 185
Hi,

I am just trying out the Logger and wondering why after setting the level to 'ALL'

any message below 'Info' (Config, Fine, ...) is not printed on the screen.

results in printing all message in the file but still only Severe, Warning and Info appears on the screen. Does anybody know why?

Thanks,

John
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5597
    
  15

My guess would be the unintuitive logging api

Try the following code snippet:


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
John Stark
Ranch Hand

Joined: Jul 19, 2011
Posts: 185
Still the same
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5597
    
  15

That's weird! When I run this little program I don't see any output on the console.


But when I uncomment line 4 the expected message is shown in the console.
John Stark
Ranch Hand

Joined: Jul 19, 2011
Posts: 185
Yes, this works. So I have to use ConsoleHandler I suppose? Thanks Roel.

John
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

Java's logging is not easy to use. Most developers prefer Log4J I think.


PM Me If You Want to get Urgent Help on Java Programming
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5597
    
  15

John Stark wrote:So I have to use ConsoleHandler I suppose?

Yes, if you want to show output on the console. If you want to write output to a file, you need a FileHandler. You could also use both (and you should even be able to set different levels for each handler). For the assignment and this certification I would suggest using ConsoleHandler, because with a FileHandler you have more issues (where to create file, what if you are in a read-only directory,...) than the ConsoleHandler. And logging is not a must requirement, so I would choose the line of least resistance.

Code snippet to set different levels for each handler:
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1512
    
    5

Nam Ha Minh wrote:Java's logging is not easy to use. Most developers prefer Log4J I think.

Yes, but in OCMJD, candidates are not allowed any third party jars (rather any jars/libraries which are not part of default JDK).

By the way, is logging a must requirement?


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5597
    
  15

Anayonkar Shivalkar wrote:By the way, is logging a must requirement?

As already mentioned in my previous post, it is not.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Roel De Nijs wrote:As already mentioned in my previous post, it is not.


That's why I didn't bother!


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

Anayonkar Shivalkar wrote:
Nam Ha Minh wrote:Java's logging is not easy to use. Most developers prefer Log4J I think.

Yes, but in OCMJD, candidates are not allowed any third party jars (rather any jars/libraries which are not part of default JDK).

By the way, is logging a must requirement?


Ok then. Logging has been added to the exam? I don't know that because I passed the SCJP 4 years ago.
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1512
    
    5

Nam Ha Minh wrote:Logging has been added to the exam?

No. Its just a way of troubleshooting the application. It is only for developer (if application fails, examiner would rather deduct the points instead of going through logs and trying to troubleshoot the application ).
Nam Ha Minh wrote:I don't know that because I passed the SCJP 4 years ago.

Did you mean SCJD? I cleared OCMJD(formerly SCJD) some 6-7 months back and logging was not a must requirement, so I didn't even go for a single bit of logging. All I did was putting print statements during debugging etc. and removing those for final version.
John Stark
Ranch Hand

Joined: Jul 19, 2011
Posts: 185
Yes, if you want to show output on the console. If you want to write output to a file, you need a FileHandler. You could also use both (and you should even be able to set different levels for each handler). For the assignment and this certification I would suggest using ConsoleHandler, because with a FileHandler you have more issues (where to create file, what if you are in a read-only directory,...) than the ConsoleHandler.

Thanks Roel. Good to know logging is not required for the exam
John
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

Anayonkar Shivalkar wrote:
Did you mean SCJD? I cleared OCMJD(formerly SCJD) some 6-7 months back and logging was not a must requirement, so I didn't even go for a single bit of logging. All I did was putting print statements during debugging etc. and removing those for final version.


Hmm... No, I mean SCJP. I didn't know that you were talking about SCJD.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logger