Logging who destroyed a cupboard?

I have a small plugin. shows who broke the tool cupboard

example: player has broken Kurbandark’s Tool Cupboard

I want my plugin to keep a record, can you help me. ı need log file

Try LogToFile method
I don't know how to do it. one of the forums made the plugin in the past
I can't share the plugin from here, I think

namespace Oxide.Plugins
{
    [Info("Tc Broken", "SSS", "1.0.0")]
    [Description("For Rust Türkiye tournament")]
    class TcBroken: RustPlugin
    {
        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            if (!(entity is BuildingPrivlidge)) return;
            var Player1 = covalence.Players.FindPlayerById(entity.OwnerID.ToString()).Name;
            var Player2 = info.InitiatorPlayer.displayName;
            var TcOwner = covalence.Players.FindPlayerById(entity.OwnerID.ToString()).Name;
            covalence.Server.Broadcast(Player2 + " Adlı Oyuncu " + TcOwner + " İnşa Dolabını Kırdı ");
        }
    }
}
namespace Oxide.Plugins
{
    [Info("TC Broken", "Author Name", "1.0.0")]
    [Description("Shows who destroyed a tool cupboard")]
    class TcBroken: CovalencePlugin
    {
        private void OnEntityDeath(BuildingPrivlidge cupboard, HitInfo info)
        {
            BasePlayer owner = BasePlayer.FindByID(cupboard.OwnerID);
            BasePlayer attacker = info?.InitiatorPlayer;
            if (owner != null && attacker != null)
            {
                server.Broadcast($"{attacker.displayName} destroyed the tool cupboard for {owner.displayName}");
            }
        }
    }
}
I want this plugin to create a log file for the messages that it send to chat, in other words, I want to have a log file
Replace:
server.Broadcast($"{attacker.displayName} destroyed the tool cupboard for {owner.displayName}");​
With:
LogToFile("filename", $"{attacker.displayName} destroyed the tool cupboard for {owner.displayName}");​
Error:
LogToFile("filename", $"{attacker.displayName} destroyed the tool cupboard for {owner.displayName}", this);​
 
It Happened Now.
How Do I Put a Time Label?
I'm using translation sorry for my english

Merged post

+++++
Timestamps are there by default in the log. You can use the standard DateTime from C# though in your message if desired.
Thank you
Also i can recommend to check foundation destroying (if TC is on it). Probably it will be not called (tc break hook)
5e13a8d5b2bc5.jpg Wulf
--snip--

Its a bit complicated when somebody asking that kind of questions. Maybe it will be better if you will make special forum? Like "Developing Questions". I remember there was similar before

using System;
namespace Oxide.Plugins
{
    [Info("TC Broken", "Author Name", "1.0.0")]
    [Description("Shows who destroyed a tool cupboard")]
    class TcBroken: CovalencePlugin
    {
        private void OnEntityDeath(BuildingPrivlidge cupboard, HitInfo info)
        {
            BasePlayer owner = BasePlayer.FindByID(cupboard.OwnerID);
            BasePlayer attacker = info?.InitiatorPlayer;
            if (owner != null && attacker != null)
            {
				server.Broadcast($"{owner.displayName} Adlı Oyuncunun İnşaat Dolabı {attacker.displayName} Adlı Oyuncu Tarafından Kırıldı.");
                LogToFile("filename", $"[{DateTime.Now}] {owner.displayName} Adlı Oyuncunun İnşaat Dolabı {attacker.displayName} Adlı Oyuncu Tarafından Kırıldı.", this);
            }
        }
    }
}


Merged post

The plugin doesn't work sometimes
I suppose because BasePlayer.FindByID finds only online players. Consider using Covalence for that: players.FindPlayerById(cupboard.OwnerID.ToString())