Created
February 20, 2018 03:27
-
-
Save joonahn/d554f3d03f50e394925afa844a94ae2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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