Recently, while working with SQL Server Agent settings, I came across an interesting issue that I would like to share with you. In this blog post, we will discuss how to fix the error message “Msg 22004 – The log file is not using Unicode format” that occurs when trying to open the SQL Server Agent Log.
When I attempted to open the SQL Server Agent Log using SQL Server Management Studio, I encountered the following error:
.Net SqlClient Data Provider —————————— The log file is not using Unicode format
Even when using the sp_readerrorlog stored procedure to read the SQL Agent Logs, the same error was displayed. However, interestingly, I was able to open and read the “SQLAGENT.OUT” file from the Windows side using a text editor like Notepad.
After some investigation, I discovered that the issue was related to the “Write OEM error log” setting in the SQL Server Agent properties. According to the documentation on MSDN, enabling this option writes the error log file as a non-Unicode file, which reduces disk space consumption but may make it more difficult to read messages with Unicode data.
So, how do we fix this issue? Initially, I noticed that the “Write OEM error log” option was disabled in the SQL Server Agent properties window. However, there is another place where we can change this setting:
- Connect to Object Explorer in SQL Server Management Studio.
- Expand “SQL Server Agent”.
- Right-click on “Error Logs” and choose “Configure”.
- Uncheck the box next to “Write OEM error log”.
If you prefer using T-SQL, you can also run the following script to fix the issue:
USE [msdb] GO EXEC msdb.dbo.sp_set_sqlagent_properties @oem_errorlog=0 GO
Once you have made the necessary changes, remember to restart the SQL Agent service. After the restart, you should be able to read the newly generated logs without encountering the “Msg 22004” error.
Have you encountered this issue before? If so, please share your experience in the comments below.