SOLR Log level Modify source code harvesting

Source: Internet
Author: User
Tags solr

Core code:

public void Setloglevel (string category, String level) {

Org.apache.log4j.Logger log;

if (LoggerInfo.ROOT_NAME.equals (category)) {

log = Org.apache.log4j.LogManager.getRootLogger ();

} else {

log = org.apache.log4j.Logger.getLogger (category);

   }

if (level==null| | " Unset ". Equals (level) | |" Null ". Equals (level)) {

log.setlevel (null);

   }

Else {

Log.setlevel (level) (Org.apache.log4j.Level.toLevel);

   }

 }

Public list<string> Getalllevels () {

return Arrays.aslist (

org.apache.log4j.Level.ALL.toString (),

org.apache.log4j.Level.TRACE.toString (),

org.apache.log4j.Level.DEBUG.toString (),

org.apache.log4j.Level.INFO.toString (),

org.apache.log4j.Level.WARN.toString (),

org.apache.log4j.Level.ERROR.toString (),

org.apache.log4j.Level.FATAL.toString (),

org.apache.log4j.Level.OFF.toString ());

 }

public collection<loggerinfo> getallloggers () {

Org.apache.log4j.Logger root = Org.apache.log4j.LogManager.getRootLogger ();

map<string,loggerinfo> Map = new hashmap<string,loggerinfo> ();

enumeration<?> loggers = Org.apache.log4j.LogManager.getCurrentLoggers ();

while (loggers.hasmoreelements ()) {

Org.apache.log4j.Logger Logger = (Org.apache.log4j.Logger) loggers.nextelement ();

String name = Logger.getname ();

if (logger = = root) {

continue;

     }

map.put (name, new Log4jinfo (name, logger));


while (true) {

int dot = Name.lastindexof (".");

if (dot < 0)

break;

name = name.substring (0, Dot);

if (!map.containskey (name)) {

map.put (name, new Log4jinfo (name, null));

       }

     }

   }

map.put (loggerinfo.root_name, New Log4jinfo (Loggerinfo.root_name, ROOT));

return map.values ();

 }

Dependency class Loggerinfo

/*

* Licensed to the Apache software Foundation (ASF) under one or more

* Contributor license agreements. See the NOTICE file distributed with

* This work for additional information regarding copyright ownership.

* The ASF licenses this file to under the Apache License, Version 2.0

* (the "License"); Except in compliance with

* The License. Obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable or agreed to writing, software

* Distributed under the License is distributed on a "as is" BASIS,

* Without warranties or CONDITIONS of any KIND, either express or implied.

* See the License for the specific language governing permissions and

* Limitations under the License.

*/

/**

* Wrapper class for Logger implementaions

*/

Public abstract class Loggerinfo implements Comparable<loggerinfo> {

public static final String root_name = "ROOT";


Protected final String name;

protected String level;


Public Loggerinfo (String name) {

THIS.name = name;

}


Public String Getlevel () {

return level;

}


Public String GetName () {

return name;

}

Public abstract Boolean isSet ();


Public Map GetInfo () {

Map info = new HashMap ();

Info.put ("Name", GetName ());

Info.put ("Level", Getlevel ());

Info.put ("Set", IsSet ());

return info;

//  }


@Override

public int CompareTo (Loggerinfo other) {

if (This.equals (other))

return 0;


String TN = This.getname ();

String on = Other.getname ();


if (Root_name.equals (TN))

return-1;

if (Root_name.equals (on))

return 1;


Return Tn.compareto (ON);

}

}

Dependency class Log4jinfo

/**

* Licensed to the Apache software Foundation (ASF) under one or more

* Contributor license agreements. See the NOTICE file distributed with

* This work for additional information regarding copyright ownership.

* The ASF licenses this file to under the Apache License, Version 2.0

* (the "License"); Except in compliance with

* The License. Obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable or agreed to writing, software

* Distributed under the License is distributed on a "as is" BASIS,

* Without warranties or CONDITIONS of any KIND, either express or implied.

* See the License for the specific language governing permissions and

* Limitations under the License.

*/



public class Log4jinfo extends Loggerinfo {

Final Org.apache.log4j.Logger Logger;


Public Log4jinfo (String name, Org.apache.log4j.Logger Logger) {

Super (name);

This.logger = logger;

}


@Override

Public String Getlevel () {

if (logger==null) {

return null;

}

Object level = Logger.getlevel ();

if (level==null) {

return null;

}

return level.tostring ();

}


@Override

Public String GetName () {

return name;

}


@Override

public Boolean IsSet () {

Return (Logger!=null && logger.getlevel ()!=null);

}

}

Using Easyui to make a simple interface and modify


SOLR Log level Modify source code harvesting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.