Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm writing two plugins at the moment which need to (optionally) log stuff...lots of stuff...somewhere. Since i don't like the 'you need to have proper permissions in this and that folder' messages of some plugins, ideally, i'd like to do it in the database.

But before i start creating my own db tables (which is also something i don't like for plugins to be doing), i'm wondering if WordPress has anything that could help with suchalike enterprise hidden in the dark deep of its codebase catacombs?

Ta.

share|improve this question
    
interesting question, i haven't heard of a hidden jam like so. –  Bainternet Feb 23 '11 at 8:54
1  
I once asked a related question about logging cron actions. The answer was simple: there is no default logging mechanism, use whatever suits you. –  Jan Fabry Feb 23 '11 at 11:07
add comment

4 Answers

I have just discovered Wordpress Logging Service plugin. Screenshots looks promising, looks maintained and it's at least past version 1.0.

share|improve this answer
add comment
up vote 2 down vote accepted

I created my own plugin and it's now available from in the repository.

(Edit: The plugin moved to its new home under the right name, so packaging and auto-update should be fine.)

share|improve this answer
    
Thanks for the plugin! This is perfect for a project I'm working on (where clients need quick access to basic event logs), and it's saving me a ton of work. I had a bit of trouble getting the plugin going though, and I tracked it down to what I think is an incorrect usage of PHP's compact function in the actual log method. You're doing something like compact($myvar), when it should be compact('myvar'). Compact will accept a var instead of a string, but only when the var is an array containing strings. Anyway, just FYI. Cool plugin! –  MathSmath Apr 4 '11 at 22:27
add comment

You can just use a hidden custom post type, like this plugin here:

http://wordpress.org/extend/plugins/log-deprecated-notices (It's written by core developer Nacin).

share|improve this answer
    
I think that's a BAD idea. It will spam your posts and potentially postmeta tables with lots of records making your whole system slower and slower pretty quickly. The only advantage i see in this is the ease of hooking into the taxation framework and the admin UI, but that doesn't really justify it. –  wyrfel Feb 23 '11 at 13:48
    
I think you mean taxonomy framework. We're not taxing anybody. :) –  scribu Feb 23 '11 at 16:23
    
@scribu LOL...indeed! –  wyrfel Feb 26 '11 at 3:59
    
@scribu: andrew's approach looks really nice to me, could you comment on whether you think @wyrfel has a valid concern? would logging 10s of 1000s of actions, thereby creating huge numbers of posts, potentially slow things down? (i'm making the assumption that those log posts are not viewable on the front end to normal visitors, they'd just be sitting in the wp_posts table and only occasionally viewed by the admin user.) –  Simon Blackbourn Feb 28 '11 at 15:22
    
Well, I've worked on installs with 300.000+ actual posts without problems. So it's mostly a matter of perception over the value of those logs. –  scribu Feb 28 '11 at 16:38
show 1 more comment

Wordpress makes use of the reliable PHP error logging. It provides an API of it's own and it's fully documented here: Error Handling and Logging and often it's already well integrated into server configurations.

For optional logging you can just use trigger_error() with it's default error-type notice (E_USER_NOTICE).

Doing so will ensure you're streamlined with wordpress error reporting and logging.


Wordpress, does not have a logging API or something that does even close to that burried down deep in it's spaghetti code. You can however make use of existing PHP based solutions that do provide high-level logging functionality like Apache Log4php which supports logging into different storages, incl. databases.

share|improve this answer
    
I'm afraid that isn't quite what i'm looking for...it's good for debug logging, yes...but what i want to log is not error or debug data. It's in one case emails the system sends out, in the other external calls to an API script, namely calls from PayPal to an IPN handler. –  wyrfel Feb 23 '11 at 9:32
    
+1 though, because your answer still helps me with debug logging –  wyrfel Feb 23 '11 at 9:34
    
wyrfel: suit yourself: logging.apache.org/log4php - I think this ships with pretty much you need. –  hakre Feb 23 '11 at 10:51
    
@hakre: It's not completely true that WordPress does not contain any logging API at all. The XML-RPC file has a very basic logging function, but it's hard to enable the global variable for it. –  Jan Fabry Feb 23 '11 at 11:17
    
Thanks everyone, i decided to write my own generic logging plugin. It's coming along quite nicely...one just does a $this->logger = new Logger('my_logger', 'My Logger') within one's 'init' callback and can then do $this->logger->log('my_log_tag', 'My Log Message', array('my' => 'log', 'entry' => 'data'));. When in Admin the same instanciation call also causes the logger to register itself, which subsequently results in a submenu being created for it under the new 'Logs' menu. Will take a little while before release, though. –  wyrfel Feb 23 '11 at 13:54
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.