I like to have the creation time of my tasks in org-mode. To that end, I used this reference to setup a hook to add the create time to a new entry. It's working pretty well but I find I'd actually like to log this in the LOGBOOK drawer instead.

This answer (which was actually referenced by the first answer) shows how to insert the CREATED property into the PROPERTIES drawer but for the life of me I can't find how I would modify that to insert into the LOGBOOK drawer instead.

As a follow-up, if someone can tell me where I could have found this that would be awesome. I looked all through the org-mode docs but couldn't really find a complete reference. The worg site has a great reference for hooks and though it says it includes commands, I'm not sure it does (e.g., org-entry-put).

2 Answers 2


The simplest solution that I can think of but which only works for TODO's from capture templates is to use the following capture template

(setq org-capture-templates
  '(("t" "todo" entry (file "~/org/inbox.org")
     "* TODO %i%? \n:LOGBOOK: \n:CREATED: %U \n:END:")))
  • That's true. Of course it would only work for creating TODOs from the capture template (and I have about a dozen of those that I'd have to update). I'm really trying to intercept the function call. Thanks for the idea, though.
    – AndyJ
    Dec 8, 2018 at 0:47
  • Yes, I misread your question and will update the answer to reflect the fact that it is incomplete.
    – andrej
    Dec 8, 2018 at 13:38

Here's a method which writes a LOGBOOK into the org file line-by-line, below the current line, which is supposed to be a newly-created heading, and includes a CREATED: timestamp in the LOGBOOK. It does hard indenting using org-cycle, because I still do that.

(defun my/insert-logbook-created-timestamp (&rest ignore)
  "Insert a LOGBOOK drawer containing a 'CREATED:' timestamp."
    ; use org-cycle to hard-indent the lines
    (newline) (org-cycle) (insert ":LOGBOOK:\n")
    (org-cycle) (insert "CREATED: ")
    (org-insert-time-stamp nil t t nil "\n" nil)
    (org-cycle) (insert ":END:")
    ; fold the LOGBOOK
    (forward-line -2) (org-cycle)))

FWIW, without indenting, the LOGBOOK writing itself can be done with a single command:

(org-insert-time-stamp nil t t ":LOGBOOK:\nCREATED: " "\n:END:" nil)

The function can be added to the desired heading insertion function, for example:

(add-hook 'org-insert-heading-hook 'my/insert-logbook-created-timestamp 'append)


(advice-add 'org-insert-todo-heading :after #'my/insert-logbook-created-timestamp)

References: Bernt Hansen's bh/insert-heading-inactive-timestamp function, @andrej in this thread, @ebpa in another thread.

For capturing, it seems the function can be added to org-capture-before-finalize-hook, see @miguelmorin in that other thread, but I haven't tested it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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