My rotation keeps resetting

Whenever I try to turn my view the rotation keeps resetting to (0,0,0)

public class PlayerView : MonoBehaviour {
	void Start () {
		Cursor.lockState = CursorLockMode.Locked;
	}
	
	void Update () {
		
		Debug.Log(Input.GetAxis("Mouse X") + "," + Input.GetAxis("Mouse Y") );

		var x = Input.GetAxis("Mouse X");
		var y = Input.GetAxis("Mouse Y");

		if (-x < 0)
		{
			x +=360;
		}

		if (y < 0)
		{
			y +=360;
		}

		transform.localRotation = Quaternion.Euler(y,-x, 0);
	}
}

I have no idea why because there is no other influence on it. So if someone could help that would be great.

I also tried to use Tranform.Rotate but then when I fill in an x and an y value my z axis also started changing.

This works for me:

using UnityEngine;

public class PlayerView : MonoBehaviour
{
    private float rotationX;
    private float rotationY;

    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }

    void Update()
    {
        

        var x = Input.GetAxis("Mouse X");
        var y = Input.GetAxis("Mouse Y");

        if (-x <= 0)
        {
            x += 360;
        }


        if (y <= 0)
        {
            y += 360;
        }

        Debug.Log(Input.GetAxis("Mouse X") + "," + Input.GetAxis("Mouse Y"));

        rotationX += x;
        rotationY += y;
        transform.rotation = Quaternion.Euler(rotationY, -rotationX, 0);
    }
}