You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Mat Brown <ma...@patch.com> on 2010/01/19 01:06:00 UTC

Specify logging options from command line in Solr 1.4?

Hi all,

Wondering if anyone can point me at a simple way to specify basic
logging options (log level, log file location) when starting the Solr
example jar from the command line.

As a bit of background, I maintain a Ruby library for Solr called
Sunspot that ships with a Solr installation for ease of use. Sunspot
includes a script for starting Solr with various options, including
logging options. With Solr 1.3, I was able to write out a
logging.properties file and then set the system property
java.util.logging.config.file via the command line; this no longer
seems to work with Solr 1.4.

I understand that Solr 1.4 has moved to SLF4J, but I haven't been able
to find a readily available answer to the above question in the SLF4J
or Solr logging documentation. To be honest, I've always found logging
in Java rather mystifying.

Any help much appreciated!
Mat

Re: Specify logging options from command line in Solr 1.4?

Posted by Mat Brown <ma...@patch.com>.
On Mon, Jan 18, 2010 at 19:15, Mark Miller <ma...@gmail.com> wrote:
> Mat Brown wrote:
>> Hi all,
>>
>> Wondering if anyone can point me at a simple way to specify basic
>> logging options (log level, log file location) when starting the Solr
>> example jar from the command line.
>>
>> As a bit of background, I maintain a Ruby library for Solr called
>> Sunspot that ships with a Solr installation for ease of use. Sunspot
>> includes a script for starting Solr with various options, including
>> logging options. With Solr 1.3, I was able to write out a
>> logging.properties file and then set the system property
>> java.util.logging.config.file via the command line; this no longer
>> seems to work with Solr 1.4.
>>
>> I understand that Solr 1.4 has moved to SLF4J, but I haven't been able
>> to find a readily available answer to the above question in the SLF4J
>> or Solr logging documentation. To be honest, I've always found logging
>> in Java rather mystifying.
>>
>> Any help much appreciated!
>> Mat
>>
> By default, even though Solr uses SLF4J, it will actually use the Java
> Util logging Impl:
>
> http://wiki.apache.org/solr/SolrLogging
>
> So you just specify a util logging properties file on the sommand line with:
>
> -Djava.util.logging.config.file=myLoggingConfigFilePath
>
> An example being:
>
> handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
>
> # Default global logging level.
> # Loggers and Handlers may override this level
> .level=INFO
>
> java.util.logging.ConsoleHandler.level=INFO
> java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
>
>
> # --- FileHandler ---
> # Override of global logging level
> java.util.logging.FileHandler.level=ALL
>
> # Naming style for the output file:
> # (The output file is placed in the directory
> # defined by the "user.home" System property.)
> java.util.logging.FileHandler.pattern=%h/java%u.log
>
> # Limiting size of output file in bytes:
> java.util.logging.FileHandler.limit=50000
>
> # Number of output files to cycle through, by appending an
> # integer to the base file name:
> java.util.logging.FileHandler.count=1
>
> # Style of output (Simple or XML):
> java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
>
>
> --
> - Mark
>
> http://www.lucidimagination.com
>
>
>
>
Hey Mark,

Thanks very much for this - using the java.util.logging properties
does indeed work just fine.

Cheers,
Mat

Re: Specify logging options from command line in Solr 1.4?

Posted by Mark Miller <ma...@gmail.com>.
Mat Brown wrote:
> Hi all,
>
> Wondering if anyone can point me at a simple way to specify basic
> logging options (log level, log file location) when starting the Solr
> example jar from the command line.
>
> As a bit of background, I maintain a Ruby library for Solr called
> Sunspot that ships with a Solr installation for ease of use. Sunspot
> includes a script for starting Solr with various options, including
> logging options. With Solr 1.3, I was able to write out a
> logging.properties file and then set the system property
> java.util.logging.config.file via the command line; this no longer
> seems to work with Solr 1.4.
>
> I understand that Solr 1.4 has moved to SLF4J, but I haven't been able
> to find a readily available answer to the above question in the SLF4J
> or Solr logging documentation. To be honest, I've always found logging
> in Java rather mystifying.
>
> Any help much appreciated!
> Mat
>   
By default, even though Solr uses SLF4J, it will actually use the Java
Util logging Impl:

http://wiki.apache.org/solr/SolrLogging

So you just specify a util logging properties file on the sommand line with:

-Djava.util.logging.config.file=myLoggingConfigFilePath 

An example being:

handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler

# Default global logging level. 
# Loggers and Handlers may override this level 
.level=INFO

java.util.logging.ConsoleHandler.level=INFO
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter


# --- FileHandler --- 
# Override of global logging level 
java.util.logging.FileHandler.level=ALL

# Naming style for the output file: 
# (The output file is placed in the directory 
# defined by the "user.home" System property.) 
java.util.logging.FileHandler.pattern=%h/java%u.log

# Limiting size of output file in bytes: 
java.util.logging.FileHandler.limit=50000

# Number of output files to cycle through, by appending an 
# integer to the base file name: 
java.util.logging.FileHandler.count=1

# Style of output (Simple or XML): 
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter


-- 
- Mark

http://www.lucidimagination.com