Can we get more information/root cause whenever an item publishing fails apart from error message shown on Tridion UI. I want to write a custom code to get more information on error rather than checking log files.
Here are the logs which are helpful during publish and their configuration:
Tridion Content Manager
Logfiles on CM/Publisher Servers:
LogFiles on Deployers:
Configuring logging level and their locations:
%TridionHome%\config on CM and Publisher servers to specify logging location and level
%httpupload%\bin\config on Deployer servers to specify logging location and level
Thus far I haven't felt a specific need to log what Tridion already logs in these logs. The information is sufficient to debug most issues. Also, templating logs are a place where you can hook in logs you want from your TBBs, since you want to log during publish.
The information about root causes is to be found in various log files. Depending where something goes wrong, you will need to look either in the Windows event logs on the publisher server, the transport log, or in the logs of your upload application, such as the deployer log.
So actually, checking logs is what you'll need to do. The information will most likely be in there, although sometimes it helps to set the logging level to debug if you're troubleshooting something difficult. If you want to check them programmatically, there's nothing to stop you doing that.