Skip to content

Instantly share code, notes, and snippets.

@joonahn
Created February 20, 2018 03:27
Show Gist options
  • Save joonahn/d554f3d03f50e394925afa844a94ae2b to your computer and use it in GitHub Desktop.
Save joonahn/d554f3d03f50e394925afa844a94ae2b to your computer and use it in GitHub Desktop.
import logging.config
import pkg_resources
resource_package = __name__
resource_path = '../logging.conf'
conf_file = pkg_resources.resource_filename(resource_package, resource_path)
print(conf_file)
logging.config.fileConfig(resource_path)
mylog = logging.getLogger("dev")
fileHandler = logging.FileHandler('test.log')
fileHandler.setLevel(logging.INFO)
mylog.addHandler(fileHandler)
mylog.log(logging.INFO, "INFO message")
mylog.error("Error message")
mylog.info("Error message")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment