users@glassfish.java.net

Re: Writing to the log file

From: Sahoo <sanjeeb.sahoo_at_oracle.com>
Date: Fri, 04 Feb 2011 12:24:16 +0530

Why do you think your main() method will be called by GlassFish? Log
inside your EJB or Servlet, they will appear in server.log.

On Friday 04 February 2011 10:18 AM, mrichngc wrote:
> I am trying to write to the server.log file and tried this. For some reason
> it's not working and it's driving me nuts. I've created an EJB and that
> logs system.out.println messages that I have in the code. but when I deploy
> my other application, I get nothing.
>
> I even tried to just write an app with 1 class(main) and deploy that with
> nothing but a log message and that doesn't work. Here is the code for my
> main class:
>
>
> package com.base.core;
>
> import java.util.logging.Logger;
>
> public class tstMain {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
>
> Logger logger = Logger.getLogger("tstMain");
> logger.info("This is a log message from the application!");
> }
>
> On the app server under Application Server, Logging, I added the package
> listed above (com.base.core.tstMain) and for the value I put "INFO"
>
> I get no log message....PLEASE HELP I AM AT MY WITS END! ! LOL
>
> }
> glassfish-2 wrote:
>
>> On the GUI, under the Application Server, there's a logging tab. There you
>> can set the log levels for the internal GF components.
>>
>> If you want to have your own applications write to the log, you can simply
>> use java.util.logging.
>>
>> So:
>>
>> [code]
>>
>> import java.util.logging.Logger;
>>
>> private Logger log = Logger.getLogger(YourClass.class.getName());
>>
>> log.info("My log message.");
>> [/code]
>>
>> By default, only WARNING and SEVERE are written to the log. If you want a
>> different log level, you can go to the Logging panel, and at the bottom
>> are Properties.
>>
>> There you can add:
>>
>> com.your.package.YourClass and INFO in the second box.
>>
>> Then your logs will show in the log file and the log viewer.
>> [Message sent by forum member 'whartung' (whartung)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=321949
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>>
>>
>>
>