logging off

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

logging off

Brian Whitman
I'm trying to disable all logging from Solr, or at least re-route it  
to a file.

I was finally able to disable Jetty logging through a custom  
org.mortbay.log.Logger class, but I am still seeing the Solr logs,  
which seem to come from java.util.logging.Logger.

Is there a thing I can do in solrconfig to do this?

-Brian

Reply | Threaded
Open this post in threaded view
|

Re: logging off

Brian Whitman

On Mar 3, 2007, at 12:56 PM, Brian Whitman wrote:

> I'm trying to disable all logging from Solr, or at least re-route  
> it to a file.
>

Hi Brian, all you have to do is create a logging.properties file and  
call this before starting up solr:

System.setProperty("java.util.logging.config.file", home+"/conf/
logging.properties");

Your logging.properties file can look like this:

---

handlers= java.util.logging.FileHandler
# Default global logging level.
.level= INFO

# default file output is in user's home directory.
java.util.logging.FileHandler.pattern = %h/Library/Application\  
Support/Your Company/solr%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter

---

And that will disable console logging. For jetty logging, you need to  
create a custom Log class that looks like this

package com.yourcompany.solr;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.solr.core.Config;
import org.apache.solr.core.SolrCore;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.servlet.SolrServlet;
import org.apache.solr.servlet.SolrUpdateServlet;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.log.Logger;
import org.mortbay.jetty.servlet.FilterHolder;
import org.mortbay.util.DateCache;

public class NoLog implements Logger
{
     private static boolean debug = System.getProperty("DEBUG",null)!
=null;
     private String name;

     static
     {
     }

     public NoLog()
     {
         this(null);
     }

     public NoLog(String name)
     {
         this.name=name==null?"":name;
     }

     public boolean isDebugEnabled()
     {
         return debug;
     }

     public void setDebugEnabled(boolean enabled)
     {
         debug=enabled;
     }

     public void info(String msg,Object arg0, Object arg1)
     {
     }

     public void debug(String msg,Throwable th)
     {
     }

     public void debug(String msg,Object arg0, Object arg1)
     {
     }

     public void warn(String msg,Object arg0, Object arg1)
     {
     }

     public void warn(String msg, Throwable th)
     {
     }

     private String format(String msg, Object arg0, Object arg1)
     {
         return "";
     }

     public Logger getLogger(String name)
     {
         if ((name==null && this.name==null) ||
             (name!=null && name.equals(this.name)))
             return this;
         return new NoLog(name);
     }

     public String toString()
     {
         return "NOLOG"+name;
     }

}

---

And then this before starting jetty

        System.setProperty("org.mortbay.log.class",  
"com.yourcompany.solr.NoLog");
        NoLog noLogger = new NoLog();
        org.mortbay.log.Log.setLog(noLogger);



Now, stop talking to yourself... :)


-Brian







Reply | Threaded
Open this post in threaded view
|

Re: logging off

Ryan McKinley-2
In reply to this post by Brian Whitman

sweet.

the logging is java logging... (not one i really know how to deal with)

Can you try setting system property like this:
http://www.exampledepot.com/egs/java.util.logging/Props.html



Brian Whitman wrote:

> I'm trying to disable all logging from Solr, or at least re-route it to
> a file.
>
> I was finally able to disable Jetty logging through a custom
> org.mortbay.log.Logger class, but I am still seeing the Solr logs, which
> seem to come from java.util.logging.Logger.
>
> Is there a thing I can do in solrconfig to do this?
>
> -Brian
>
>

Reply | Threaded
Open this post in threaded view
|

Re: logging off

Chris Hostetter-3
In reply to this post by Brian Whitman

: Hi Brian, all you have to do is create a logging.properties file and
: call this before starting up solr:
:
: System.setProperty("java.util.logging.config.file", home+"/conf/
: logging.properties");

it's not neccessary to execute any javacode to configurate
java.util.logging ... that property can be set on the commandline before
executing java.

: And that will disable console logging. For jetty logging, you need to
: create a custom Log class that looks like this

i'm no jetty expert, but this should also be controllable via jetty
configs, without writting any custom code .. greping the xml files in the
example/etc for "log" should turn up a lot of pointers ... much of what is
there is commented out by default -- and i believe that's why it goes to
STDOUT instead of specific files.


-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: logging off

Bill Au
FYI, the admin page has a link, [LOGGING], that can be use to change Solr's
logging on the fly.

Bill

On 3/4/07, Chris Hostetter <[hidden email]> wrote:

>
>
> : Hi Brian, all you have to do is create a logging.properties file and
> : call this before starting up solr:
> :
> : System.setProperty("java.util.logging.config.file", home+"/conf/
> : logging.properties");
>
> it's not neccessary to execute any javacode to configurate
> java.util.logging ... that property can be set on the commandline before
> executing java.
>
> : And that will disable console logging. For jetty logging, you need to
> : create a custom Log class that looks like this
>
> i'm no jetty expert, but this should also be controllable via jetty
> configs, without writting any custom code .. greping the xml files in the
> example/etc for "log" should turn up a lot of pointers ... much of what is
> there is commented out by default -- and i believe that's why it goes to
> STDOUT instead of specific files.
>
>
> -Hoss
>
>