18May, 2022
Who Published That? When? Use My Publish History Module to Always Be In the Know!
One of our clients asked me last week if I could find out when a specific page was published. This action gets recorded into the logs so you can always check there, but it's only retained for a few days. My Publish History module stores a permanent record on each item for when something was published, and by who.
What's in the Logs?
You can use Sitecore logs to see who's publishing items, but the CleanupAgent will remove these loge files at some point. You can always change this behaviour by patching the maxAge value as seen below. This example sets the max age of logs to 10 days.
<configuration...> <sitecore> <scheduling> <agent type="Sitecore.Tasks.CleanupAgent" method="Run" interval="06:00:00" > <files hint="raw:AddCommand"> <remove folder="$(dataFolder)/logs" pattern="*log.*.txt*" maxAge="10.00:00:00" recursive="true" /> </files> </agent> </scheduling> </sitecore> </configuration>
As said, the logs will hold the publish information in the following format, but there's a couple of problems with it. First, you need to go to the logs, which isn't something authors are going to know how, or want to do. Also, this kind of log isn't going to exist if something published due to the Sitecore.Tasks.PublishAgent (Scheduled Publish).
6136 13:47:24 INFO AUDIT (sitecore\jasonmaclean): Publish item now: master:/sitecore/content/Home, language: en, version: 1, id: {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}
The Publish History Module
This module is easy to install and is compatible with all versions of Sitecore 8 and above. All you need to do, is install the update package, and then add the base template "sitecore/templates/Modules/PublishHistory/_LastPublished" to any items you want this to be used.
Once installed, you can see the two new fields Last Published and Last Published By, seen below in the Statistics data section. If you don't see this area, just go to the View tab at the top of your Content Editor and make sure Standard Fields is checked.
If the item is published by a User, or a User executing a step of a Workflow that publishes it, then their name appears:

If an item is published due to a schedule, it will indicate this, including the last User who edited it:

You can see the complete solution on my GitHub page for the Sitecore Publish History module. Have a look and let me know if you have any questions or feedback!
Thinking of You!
On a final note, any text that would appear in the fields or logs are set in the PublishHistory.config file in case your team is using another language than English.