Strage Logging Problem

View: New views
6 Messages — Rating Filter:   Alert me  

Strage Logging Problem

by Steve Mosley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everybody,

Three weeks into a Netbeans Platform project, and loving it ... such a simple way to make a sharp looking app, compared to writing a swing app from scratch



I have a strange issue I've found with logging today, not sure if im doing something incredibly stupid ... I'm using 6.7.1 of Platform and IDE and when I run the app from the IDE I get strange behavior in the output window back in the IDE




Code:


private Logger log = Logger.getLogger(MessageService.class.getName());



    public void submitMessage(String message) {

        log.info("Message with a  \n in it");

    }







When the this log is hit the first time the output is


Code:
Message with a  



the second and subsequent times it will be


Code:
 in itMessage with a  





If I change the code to not have a line break


Code:
log.info("Message without a  \\n in it");



I'll get


Code:
INFO [com.metservice.castlepoint.server.MessageService]: Message without a  \n in it





Or if I have a line break and pass an exception




Code:
log.log(Level.INFO,"Message with a  \n in it", new Exception("Test"));



it returns what I expect as well


Code:
INFO [com.metservice.castlepoint.server.SigmetService]: Message with a  

 in it

java.lang.Exception: Test

...

...







I haven't used java.util.logging before (i'm a Log4j and Slf4j guy) ... but I don't think having line breaks in a log message is crazy.

So just want to check that im using the java.util.logging stuff correctly? or is it possible a bug in the netbeans log handler?





Re: Strage Logging Problem

by Jesse Glick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

smozely wrote:
> I don't think having line breaks in a log message is crazy.

It's quite possible newlines inside a log message are simply not supported. If you want to output multiple lines, log several messages.


Strange Logging Problem

by Steve Mosley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some more testing and using line breaks in a simple console app that uses java.util.logging works fine with line breaks ...



Personally I don't think that someone would intentionally write a Logger that didn't allow line breaks.



But as I showed in my examples something more sinister is happening here ... given that when log messages are getting mixed with the previous message, and when you pass an exception everything works as expected.



So is there a Netbeans logging handler being called somewhere here? this seems like a bug to me, I just checking the it definitely isn't a bug before I raise it as one.





Re: Strange Logging Problem

by Jesse Glick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

smozely wrote:
> So is there a Netbeans logging handler being called somewhere here?

Yes, NB installs its own log handler.

> this seems like a bug to me, I just checking the it definitely isn't a bug before I raise it as one.

Feel free to http://wiki.netbeans.org/DevFaqFileBug with a test case to reproduce.


Strange Logging Problem

by Steve Mosley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Will do,



just to make it as useful as possible ...



Which Component/Subcomponent do you think this should come under.



Also I had a question a couple of weeks ago about the way logging is broken with multi line strings ...  a recommended Component/Subcomponent for that?



Both of them I was thinking platform component ... but no idea for the sub





Cheers

Steve





Re: Strange Logging Problem

by Jesse Glick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

smozely wrote:
> Also I had a question a couple of weeks ago about the way logging is broken with multi line strings ...  a recommended Component/Subcomponent for that?
>
> Both of them I was thinking platform component ... but no idea for the sub

'other' is fine. It will get reassigned if you pick wrong so don't worry too much about it.