site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Hi, Thanks a lot for any hints, tips, suggestions, etc. Best regards, Gabriel. --- code _________________________________________________________________ Tradition is not worshipping the ashes, it’s carrying on the fire. (Gustav Mahler) _________________________________________________________________ _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... i really would like to log messages from my app with log level ASL_LEVEL_INFO through the asl API. Alternatively, i could live with a separate log file, but i wasn't able to achieve that either. Does anybody know how to do that without editing syslog.conf, or any other "sudo" commands? I am able to log messages at level "notice". I have searched the lists quite a bit, to no avail. Below you can find some code that i tried. Please note that that code is just a snapshot of many variations i have experimented with. const char *log_file = "/var/log/artsaver.log"; log_client_ = asl_open( NULL, NULL, 0 ); if ( ! log_client_ ) syslog( LOG_ERR, "ArtSaver: asl_open failed: %m!" ); else { log_msg_ = asl_new( ASL_TYPE_MSG ); asl_set( log_msg_, ASL_KEY_SENDER, "ArtSaver"); asl_set_filter( log_client_, ASL_FILTER_MASK_UPTO (ASL_LEVEL_DEBUG) ); // raus? asl_set_filter( NULL, ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG) ); umask( S_IXUSR | S_IRWXG | S_IRWXO ); int fd = open( log_file, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR ); if ( ! fd ) syslog( LOG_ERR, "ArtSaver: open(%s) failed: %m!", log_file ); else asl_add_log_file( log_client_, fd ); asl_log( NULL, log_msg_, ASL_LEVEL_NOTICE, "asl: testing logging." ); // alt. ASL_LEVEL_ERR or ASL_LEVEL_INFO asl_log( NULL, NULL, ASL_LEVEL_NOTICE, "Hello World!" ); } This email sent to site_archiver@lists.apple.com
participants (1)
-
Gabriel Zachmann