スキップしてメイン コンテンツに移動

投稿

ラベル(Logging)が付いた投稿を表示しています

Static Access to Symfony2 Logger

If you would like to use logging functionality in Symfony2, you should access logger service via container. For example in controller, you can easily access container and access logger service. $logger = $this->get('logger'); $logger->info('I just got the logger'); $logger->error('An error occurred'); Well, that's it. However, this is big however for me, what should I do when accessing logger not from controller class? Of course you can pass container or logger service itself to the class in service.yml service_use_logger: class: LoggingExample\Service\ServiceUsingLogger arguments: - @logger A bit pain everytime we should passing logger to the service class if you would like to use logger. For Java or .Net, I have never seen general logging functionality is provided from dependency injection container. For Almost all logging library, logger can be accessible as static - for example log4j. I tried to make logging functio

.Net用のLogツール

log4net .Net用の強力なLoggingツールです。Log4Jの.Net版といったところでしょうか。 解説サイト O'Reillyの WindowsDevCenter.com の このページ が大変参考になります。 @ITの このページ も参考になります。