You should use a logging framework or some other abstraction so your code is not tightly coupled to AWS CloudWatch. Then you can easily change the log destination (CloudWatch, file, database) without changing your code.
For example, let's say you're using .NET. Here is how you can configure popular .NET logging frameworks to send logs to CloudWatch. Or here is a solution for Python. I'm sure there are similar solutions in other languages/frameworks.
If you are already generating log files, another option is to use the CloudWatch Agent to send those existing logs to CloudWatch.