Coder Social home page Coder Social logo

Default logLevel DEBUG or INFO? about ixmp HOT 5 CLOSED

iiasa avatar iiasa commented on May 20, 2024
Default logLevel DEBUG or INFO?

from ixmp.

Comments (5)

danielhuppmann avatar danielhuppmann commented on May 20, 2024

Sorry, I believe that the output in your screenshot is determined in the compiled ixmp.jar, and this is distinct from the _LOGGER.setLevel(). Not sure why this was changed in the first place before the latest release.

We will rework the Java logging in the next release.

from ixmp.

tzipperle avatar tzipperle commented on May 20, 2024

Make sense, because I could not get access via the python logging root handler...

from ixmp.

gidden avatar gidden commented on May 20, 2024

@zikolach and @fonfon would it be possible to access and set the log level in java from python as well?

from ixmp.

zikolach avatar zikolach commented on May 20, 2024

@gidden you can do it by programmatically by calling e.g.:

org.apache.log4j.Logger.getLogger(Platform.class.getPackage().getName()).setLevel(org.apache.log4j.Level.DEBUG)

Alternatively I can add a (static) method to Platform class for setting it. But we have bundled log4j.properties file with some predefined settings:

log4j.appender.FA=org.apache.log4j.DailyRollingFileAppender
log4j.appender.FA.file=D:/tmp/GasmAgeServlet-app.log
log4j.rootLogger=FA, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %5p %c:%L - %m%n
log4j.logger.at.ac.iiasa.kolp.cleanage.servlet.DatabaseHelper=info
log4j.logger.at.ac.iiasa.ixmp.servlet.AuthDbFilter=info
log4j.logger.at.ac.iiasa.ixmp.servlet.RestServlet=debug

which I would replace with

log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %5p %c:%L - %m%n
log4j.logger.org.flywaydb.core.internal=warn

as default

from ixmp.

khaeru avatar khaeru commented on May 20, 2024

Hi @tzipperle β€”going to close this now since the code is substantially changed and I don't suspect this can occur anymore. Now, the top-level ("ixmp") logger is configured here:

ixmp/ixmp/__init__.py

Lines 44 to 48 in 59e99e4

# Configure the 'ixmp' logger: write messages to std out, defaulting to level
# WARNING and above
log = logging.getLogger(__name__)
log.addHandler(logging.StreamHandler())
log.setLevel(logging.WARNING)

The Java backend, at the point when any new Platform is instantiated, uses either a user argument or copies this value:

ixmp/ixmp/backend/jdbc.py

Lines 212 to 216 in 59e99e4

# Extract a log_level keyword argument before _create_properties().
# By default, use the same level as the 'ixmp' logger, whatever that
# has been set to.
ixmp_logger = logging.getLogger('ixmp')
log_level = kwargs.pop('log_level', ixmp_logger.getEffectiveLevel())

After this, the mp.set_log_level() method can be used to control the log messages emitted from Java. At any time or point, the "ixmp" logger can be manipulated in the usual Python way.

If any similar issue is still happening with the newest code, please open a new issue.

from ixmp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.