3

I'd like to change the Date format of recent log messages (/admin/reports/dblog) in Drupal 8.9.1 from short date to something with the time. In Drupal 7 using watchdog I just edited the view and it was done. Since moving logging into core, I can't figure out where to edit the view. There is no view listed for Recent Log Messages or dblog and I can't find any other way to edit the date format. It's not an option in /admin/config/development/logging.

I know I can change Short Date globally to include time but I'm hesitant to change it everywhere just for an admin page. It seems like my only option is to create a new view with what I want and then replace the Recent page altogether.

Any help would be greatly appreciated.

dblog view short date

3 Answers 3

4

This is still a view. The "Watchdog" view. Go to /admin/structure/views/view/watchdog and edit the date format. That's all.

6
  • I get a page not found, unfortunately. Commented Jun 22, 2020 at 19:59
  • 3
    @PhillipJubb – Seems you either didn't enable the Views UI module or you don't have the right permissions.
    – leymannx
    Commented Jun 22, 2020 at 20:04
  • That gave me an idea to try with the user 1 admin account but unfortunately it didn't work either. I'm an admin but it was worth a shot. Views UI is installed and enabled. Commented Jun 22, 2020 at 20:22
  • @PhillipJubb – Did you try this a fresh standard installation? Or what profile are you using? Can you access /admin/structure/views at all? And there is no "Watchdog" view?
    – leymannx
    Commented Jun 22, 2020 at 20:38
  • 1
    @PhillipJubb – Is it really /admin/report/dblog or is it /admin/reports/dblog? Did you scan the codebase for the path?
    – leymannx
    Commented Jun 22, 2020 at 21:01
3

Ok, using @leymannx's shock that I could access views and yet the watchdog view wasn't there, I did a grep of watchdog and found the following entry in /core/modules/dblog/dblog.post_update.php:

/** Replace 'Recent log messages' with a view.*/
function dblog_post_update_convert_recent_messages_to_view() {
  // Only create if the views module is enabled and the watchdog view doesn't
  // exist.

This lead me to assume that when the module was enabled/added, my views module WASN'T enabled and so no view created for watchdog. I uninstalled dblog, checked again that Views was enabled, and re-enabled dblog. The watchdog view was created!

Thanks.

1

Short answer is change the date format in the view:

  1. Change the date format used in the view at /admin/structure/views/view/watchdog

or

  1. Edit the date format itself, that the view is using (which you don't want to do), so create a new one, at /admin/config/regional/date-time/formats/add and select that one in the view.

The default view that Watchdog reports uses on my D8 installation is the "Short Date Format", which out of the box includes the date and time in the php format m/d/Y - H:i e.g 06/22/2020 - 15:47

1
  • That was the issue though, I couldn't edit the view at all because the watchdog view wasn't there. It wasn't really about the date but about the missing view. I just didn't know that when I first asked the question. Appreciate the help though. Commented Jun 23, 2020 at 4:52

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.