Results 1 to 9 of 9

Thread: stop spring logging for console?

  1. #1
    Join Date
    Jul 2006
    Posts
    154

    Default stop spring logging for console?

    hi..


    i'm a newbie for spring, is i'm trying it out with a simple bean injection with i can barely see my console output from all the logging spring puts out, is there a way i stop it temporely (or at least aim to a file?)

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    You need to configure your logging system properly.

    Let me explain. Spring uses Commons Logging, like most open source and many commercial products. Commons Logging is an adapter API that sits on top of other logging frameworks. Put log4j on your classpath and configure an appropriate log4j.properties file. See the Spring sample apps as an example. This way you can see as little or as much Spring logging as you want, and send it to any file you want.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Jul 2006
    Posts
    154

    Default well i added log4j

    but now i get
    og4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).
    log4j:WARN Please initialize the log4j system properly.

    even after adding a log4j.properties file.

  4. #4
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    668

    Default Log4J isn't configured properly

    This means your log4j configuration either isn't correct or isn't on the classpath. Either way, it's not a Spring issue, so you're best off seeking help in more appropriate places, e.g. the Log4J web site (http://logging.apache.org/log4j/docs), or Google for one of the many Log4J tutorials.

    HTH,
    Andrew Swan
    "Now is the EJB of our discontent made glorious Spring"

  5. #5
    Join Date
    Jul 2006
    Posts
    154

    Default considering the fact that i'm using eclipse

    and that i tried placing the log files into eclipse root, the library where log4j sits, and in workspace, i'm running out of options

  6. #6
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    If you place log4j.properties in the root of a source folder, eclipse will be happy. In that case the file will be automatically copied to the "bin" folder and therefore will be picked up from the classpath.

    Regards,
    Andreas

  7. #7
    Join Date
    Jul 2006
    Posts
    154

    Default well it was copied from the source to bin

    but i stilll got the warning messages.

    isn't there a system property i should add in eclispe run config?

    btw this is what the properties have:
    log4j.rootLogger=INFO, stdout, logfile

    log4j.appender.stdout=org.apache.log4j.ConsoleAppe nder
    log4j.appender.stdout.layout=org.apache.log4j.Patt ernLayout
    log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n

  8. #8
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    668

    Lightbulb Try this...

    In the Eclipse "Run" dialog, do this:
    1. Choose the "Classpath" tab
    2. Select "User Entries" in the displayed tree
    3. Click the "Advanced..." button
    4. Select "Add Folders" and click OK
    5. Select the folder containing log4j.properties (or log4j.xml) and click OK
    6. Click "Run"
    This folder will stay on your classpath next time you run that item, so you only need to do those steps once per test case (or whatever it is you're running).

    HTH,
    Andrew Swan
    "Now is the EJB of our discontent made glorious Spring"

  9. #9
    Join Date
    Jul 2006
    Posts
    154

    Default thanks that did the trick...

    i've re-routed everything to a log file so my output won't get garbled...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •