{"id":21056012,"url":"https://github.com/xp-framework/logging","last_synced_at":"2025-09-13T08:17:15.048Z","repository":{"id":36897391,"uuid":"41204398","full_name":"xp-framework/logging","owner":"xp-framework","description":"Logging for the XP Framework","archived":false,"fork":false,"pushed_at":"2024-03-28T22:24:03.000Z","size":185,"stargazers_count":0,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-24T12:50:32.850Z","etag":null,"topics":["ini","logging","php","syslog","xp-framework"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xp-framework.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-08-22T11:34:54.000Z","updated_at":"2021-10-21T14:48:21.000Z","dependencies_parsed_at":"2023-12-02T11:26:19.657Z","dependency_job_id":"7ccee92f-2f53-47f9-8470-e43d4df45217","html_url":"https://github.com/xp-framework/logging","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/xp-framework/logging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Flogging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Flogging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Flogging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Flogging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-framework","download_url":"https://codeload.github.com/xp-framework/logging/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Flogging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274936006,"owners_count":25376838,"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","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ini","logging","php","syslog","xp-framework"],"created_at":"2024-11-19T16:48:16.767Z","updated_at":"2025-09-13T08:17:14.993Z","avatar_url":"https://github.com/xp-framework.png","language":"PHP","readme":"Logging\n=======\n\n[![Build status on GitHub](https://github.com/xp-framework/logging/workflows/Tests/badge.svg)](https://github.com/xp-framework/logging/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-framework/logging/version.png)](https://packagist.org/packages/xp-framework/logging)\n\nLogging for the XP Framework.\n\nExample\n-------\n\n```php\nuse util\\log\\Logging;\nuse lang\\Throwable;\nuse peer\\ConnectException;\n\n$logger= Logging::named('service')-\u003etoConsole();\n$logger-\u003einfo('Starting application');\n\ntry {\n  $service-\u003eoperation();\n} catch (ConnectException $e) {\n  $logger-\u003ewarn('Service not available', $e);\n} catch (Throwable $t) {\n  $logger-\u003eerror('Error during service invocation', $t);\n}\n```\n\nLevels\n------\nThis library supports the following levels: DEBUG, INFO, WARN and ERROR. As seen above, messages can be logged using methods named after these levels. All methods have a *printf*-style variant:\n\n* `debug(var... $args)` and `debugf(string $format, var... $args)`.\n* `info(var... $args)` and `infof(string $format, var... $args)`.\n* `warn(var... $args)` and `warnf(string $format, var... $args)`.\n* `error(var... $args)` and `errorf(string $format, var... $args)`.\n\nAppenders\n---------\nThe following appenders are available:\n\n* `util.log.FileAppender(string $filename)` - Logs to a local file\n* `util.log.ConsoleAppender()` - Logs to console\n* `util.log.ColoredConsoleAppender()` - Logs to console using colors depending on log level\n* `util.log.SmtpAppender(string $email, string $prefix= \"\", bool $sync= true)` - Logs by email to a given email address\n* `util.log.StreamAppender(io.streams.OutputStream $out)` - Logs to any output stream from `io.streams`.\n* `util.log.SyslogAppender(string $identifier, int $facility= LOG_USER)` - Logs using syslog facility\n* `util.log.SyslogUdpAppender(string $ip= '127.0.0.1', int $port= 514, string $identifier= null, int $facility= LOG_USER, string $hostname= null)` - Logs using syslog protocol over UDP\n* `util.log.BufferedAppender()` - Logs to a memory buffer\n\nLayout\n------\nThe default log layout includes time, pid, level and message implemented by the `util.log.layout.DefaultLayout` class. It renders as follows:\n\n```\n[13:43:39  4368  info] Starting application\n```\n\nThe log layout can be changed by instantiating the `util.log.layout.PatternLayout`, passing a format string and using the appenders `setLayout()` method to use it. The format string consists of format tokens preceded by a percent sign (%) and any other character. The following format tokens are \nsupported:\n\n* `%m` - Message\n* `%c` - Category name\n* `%l` - Log level - lowercase\n* `%L` - Log level - uppercase\n* `%d` - Date in YYYY-MM-DD\n* `%t` - Time in HH:MM:SS\n* `%p` - Process ID\n* `%%` - A literal percent sign (%)\n* `%n` - A line break\n* `%x` - Context information, if available\n\nConfiguration\n-------------\nInstead of using the [Logging DSL](https://github.com/xp-framework/logging/pull/6) to create your log setup programmatically, you can use the [configuration API](https://github.com/xp-framework/logging/pull/12), which works with INI files:\n\n```ini\n[default]\nuses=console|syslog|files\n\n[console]\nclass=util.log.ConsoleAppender\nlevel=ALL\n\n[files]\nclass=util.log.FileAppender\nargs=\"/var/log/server.log\"\nlevel=ALL\n\n[syslog]\nclass=util.log.SyslogUdpAppender\nargs=127.0.0.1|514|server\nlevel=WARN|ERROR\n```\n\nFurther reading\n---------------\n* [Log Contexts](https://github.com/xp-framework/xp-framework/pull/239)\n* [Support for rolling file names](https://github.com/xp-framework/xp-framework/pull/353)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-framework%2Flogging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-framework%2Flogging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-framework%2Flogging/lists"}