If you want to log error in 15 hive Logs folder than you have to use Diagnostics.asmx web service.
You can find list of all web service library on this link :
https://msdn.microsoft.com/en-us/library/office/jj193051.aspx
SharePointDiagnostics web service is used to communicate with Microsoft SharePoint Foundation 2010 diagnostic services. Client applications can call this web service to report errors and other diagnostic data.
We will use SendClientScriptErrorReport method present inside SharePointDiagnostics class.
Now lets get started –
Step 1 – Include _vti_bin/Diagnostics.asmx web service in your project.
Step 2 – Now make an object of SharePointDiagnostics class present in the web service reference.
Step 3 – Pass Credentials to SharePointDiagnostics class object.
Step 4 – Call SendClientScriptErrorReport method in SharePointDiagnostics class and pass (string message, string file, int line, Client client, string stack, Team team, string originalFile as arguments)
For example –
/// <param name="message">A string containing Message to be logged.</param>
/// <param name="file">A string containing the location of the file from which the error is being generated.</param>
/// <param name="line">A string containing the line of code from which the error is being generated.</param>
/// <param name="client">A string containing the client name that is experiencing the error.</param>
/// <param name="stack">A string containing the call stack information from the generated error.</param>
/// <param name="team">A string containing a team or product name.</param>
/// <param name="originalFile">A string containing the original file name.</param>
SharePointDiagnostics SharePointDiagnosticsObject = new SharePointDiagnostics();
SharePointDiagnosticsObject.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
string Response = SharePointDiagnosticsObject.SendClientScriptErrorReport(message, file, line, client, stack, team, originalFile);

can I change area using above code?
I don’t think so because the given method does not provide any implementation that could change area, category or severity.
[…] Utilize diagnostics.asmx web service – I have explained how to write log in Hive 15 log file in my previous blog (How to do logging in ULS from CSOM in c#?). […]
This approach works on prem and SPO, but I am unable to access the logs. Do you have any ideas?
What do you mean by ‘unable to access the logs’? Please elaborate your question.
It is my understanding that there is no way to view ULS logs on SharePoint Online. If it is not the case, please let me know how to access it
thats right, you can’t view ULS logs on SharePoint Online