{"id":18309557,"url":"https://github.com/sfuhrm/logwebconfig","last_synced_at":"2025-04-09T11:42:40.041Z","repository":{"id":57730924,"uuid":"140199924","full_name":"sfuhrm/logwebconfig","owner":"sfuhrm","description":"Logging configuration using a REST API","archived":false,"fork":false,"pushed_at":"2018-07-13T20:22:59.000Z","size":71,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T05:42:14.411Z","etag":null,"topics":["configuration","http","http-server","log4j","log4j2","logging","rest","rest-api","runtime-config"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sfuhrm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-08T20:21:51.000Z","updated_at":"2018-07-13T20:23:01.000Z","dependencies_parsed_at":"2022-09-26T22:01:40.927Z","dependency_job_id":null,"html_url":"https://github.com/sfuhrm/logwebconfig","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfuhrm%2Flogwebconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfuhrm%2Flogwebconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfuhrm%2Flogwebconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfuhrm%2Flogwebconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sfuhrm","download_url":"https://codeload.github.com/sfuhrm/logwebconfig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248033216,"owners_count":21036755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","http","http-server","log4j","log4j2","logging","rest","rest-api","runtime-config"],"created_at":"2024-11-05T16:11:48.834Z","updated_at":"2025-04-09T11:42:40.020Z","avatar_url":"https://github.com/sfuhrm.png","language":"Java","readme":"Log Web Config\n===================\n![Travis CI Status](https://travis-ci.org/sfuhrm/logwebconfig.svg?branch=master)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/3d9b5025bb484534b9daab2fc5f3da73)](https://www.codacy.com/app/sfuhrm/logwebconfig?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=sfuhrm/logwebconfig\u0026amp;utm_campaign=Badge_Grade)\n[![Coverage Status](https://coveralls.io/repos/github/sfuhrm/logwebconfig/badge.svg)](https://coveralls.io/github/sfuhrm/logwebconfig) \n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/de.sfuhrm/logwebconfig/badge.svg)](https://maven-badges.herokuapp.com/maven-central/de.sfuhrm/logwebconfig) \n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n\nA simple runtime REST-based configuration of the logging facility.\nYou can query and modify the log levels of each and every logger inclusive the root logger with one HTTP PUT request.\n\n#### Target scenarios\n\nThe library comes handy for the following scenarios:\n* Non-JEE application. JEE servers usually have frontends for configuring the log levels.\n* Applications of which you control the source.\n* Long-running server application. \n* Java 8+ application runtime.\n\n#### Features\n\nThe features of this small library are:\n* Get (HTTP GET) and modify (HTTP PUT) the log levels of loggers of your\nlogging framework.\n* Can interoperate with multiple logging frameworks. At the moment log4j1 and log4j2 is implemented.\n* Small footprint using a [mini](https://github.com/NanoHttpd/nanohttpd) http server.\n\n#### Pros and cons\n\nThe advantages of configuring the log levels at runtime are:\n* Changes get active promptly. No need to copy config files to many servers in a cluster.\n* Changes get active smoothly. No need to restart applications.\n* Changes can be configured easily. No long XML, JSON or properties files.\n* Safe configuration. No risk of logging configuration files to be malformed.\n\nThe disadvantages are:\n* There's a http server thread running besides your application.\n* There's one more TCP/IP port to worry about. One more iptables / ACL\nto write if your organisation does whitelisting of ports.\n\n## Including it in your projects\n\nThe recommended way of including the library into your project is adding the\nfollowing Apache Maven dependency:\n\n---------------------------------------\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ede.sfuhrm\u003c/groupId\u003e\n    \u003cartifactId\u003elogwebconfig\u003c/artifactId\u003e\n    \u003cversion\u003e0.8.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n---------------------------------------\n\nAt program start you need to call the service once so the\nserver starts up:\n\n---------------------------------------\n\n```java\nimport de.sfuhrm.logwebconfig.LogWebConfig;\n\npublic class MyApp {\n    public static void main(String args[]) {\n        LogWebConfig.start();\n        \n        // your program comes here\n    }\n}\n```\n\n---------------------------------------\n\n## Startup time: Configuring the server\n\nConfiguration of the server is done using Java system properties.\nBy default the server listens on TCP/IP port 19293.\n\nThe following properties are there for configuration:\n\n* **LOGWEBCONFIG_PORT**: The TCP/IP port for the HTTP-server to listen to. Example value is 19293 which is also the default port.\n* **LOGWEBCONFIG_HOST**: The IP address to bind the listening socket to. Defaults to \"127.0.0.1\" which is only reachable from localhost.\nThis can be used to restrict the accessibility of the configuration from outside. Exposing the service to the internet by listening to all addresses (\"0.0.0.0\")\nmight be a security risk because you can put the root logging level of your application to debug.\n* **LOGWEBCONFIG_ENABLE**: Whether to enable the server. Defaults to true.\n* **LOGWEBCONFIG_USER**: Username to use for HTTP basic authentication of the client. Defaults to no authentication.\n* **LOGWEBCONFIG_PASSWORD**: Password to use for HTTP basic authentication of the client. Defaults to no authentication.\n\nExample for listening on all interface addresses on port 54321:\n\n---------------------------------------\n\n```Shell\njava -DLOGWEBCONFIG_PORT=54321 -DLOGWEBCONFIG_HOST=0.0.0.0 -jar myjar.jar ...\n```\n\n---------------------------------------\n\n## Run time: Configuring log4j1\n\nLog4j1 is configured by simply issueing PUT requests with the logger seen as a\nresource and the log level as a request parameter.\n\nExample for setting the root logger level:\n\n---------------------------------------\n```Shell\ncurl -X PUT -d WARN http://localhost:19293/log4j1//level\n```\n---------------------------------------\n\nExample for setting the logger level for class 'com.company.my.Class':\n\n---------------------------------------\n```Shell\ncurl -X PUT -d WARN http://localhost:19293/log4j1/com.company.my.Class/level\n```\n---------------------------------------\n\nExample for getting the root logger level:\n\n---------------------------------------\n```Shell\ncurl -X GET  http://localhost:19293/log4j1//level\nERROR\n```\n---------------------------------------\n\n\n## Run time: Configuring log4j2\n\nLog4j2 is configured by simply issueing PUT requests with the logger seen as a\nresource and the log level as a request parameter.\n\nExample for setting the root logger level:\n\n---------------------------------------\n```Shell\ncurl -X PUT -d WARN http://localhost:19293/log4j2//level\n```\n---------------------------------------\n\nExample for setting the logger level for class 'com.company.my.Class':\n\n---------------------------------------\n```Shell\ncurl -X PUT -d WARN http://localhost:19293/log4j2/com.company.my.Class/level\n```\n---------------------------------------\n\nExample for getting the root logger level:\n\n---------------------------------------\n```Shell\ncurl -X GET  http://localhost:19293/log4j2//level\nERROR\n```\n---------------------------------------\n\n## Versions\n\nThe version numbers are chosen according to the\n[semantic versioning](https://semver.org/) schema.\nEspecially major version changes come with breaking API\nchanges.\n\n## Author\n\nWritten 2018 by Stephan Fuhrmann. You can reach me via email to s (at) sfuhrm.de\n\n## License\n\nCopyright 2018 Stephan Fuhrmann\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License. \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfuhrm%2Flogwebconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsfuhrm%2Flogwebconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfuhrm%2Flogwebconfig/lists"}